zoukankan      html  css  js  c++  java
  • Vue 常用指令

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    
    <body>
        <div id="app">
            <h2>1、{{}}双括号输出文本内容</h2>
            <!-- 文本内容 -->
            <p>{{msg}}</p>
            <input type="text" v-model="msg">
            <!-- 可以直接使用js表达式 -->
            <p>{{score+1}}</p>
            <h2>2、一次性插值 v-once</h2>
            <span v-once>{{msg}}</span>
            <h2>3、输出HTML内容 v-html</h2>
            <p v-html="contentHtml"></p>
    
            <h2>4、元素绑定指令 v-bind</h2>
            <img v-bind:src="imgUrl" >
            <!-- 简写方式 -->
            <img :src="imgUrl" >
    
            <h2>5、事件绑定指令</h2>
            <input type="text" name="" id="" v-model="num">
            <button v-on:click="addCli">加一</button>
            <!-- 简写方式 -->
            <button @click="addCli">简写方式加一</button>
        </div>
        <script src="./node_modules/vue/dist/vue.js"></script>
        <script>
            new Vue({
                el: '#app',//指定被Vue管理的入口
                data: {
                    msg: 'Vue.js',
                    score: 100,
                    contentHtml: '<span style="color:red">我是html</span>',
                    imgUrl:'https://cn.vuejs.org/images/logo.png',
                    num:1
                    
                },
                methods: {
    
                    addCli:function(){
                        this.num++;
                    }
                }
            })
        </script>
    
    </body>
    
    </html>
    
  • 相关阅读:
    TYVJ1061 Mobile Service
    TYVJ1061 Mobile Service
    KMP 模板
    poj 3254 Corn Field
    poj 3254 Corn Field
    洛谷1279 字串距离
    poj 1041 John's trip——欧拉回路字典序输出
    bzoj 3033 太鼓达人——欧拉图搜索
    bzoj 2503 相框——思路
    bzoj 2935 [Poi1999]原始生物——欧拉回路思路!
  • 原文地址:https://www.cnblogs.com/guozhe/p/14848879.html
Copyright © 2011-2022 走看看