Vue常用指令:

v-text:

<!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">    <title>Title</title>    <script src="./static/vue.min.js"></script></head><body>    <div id="app" v-text="greeting"></div>    <script>        // 数据模板引擎:        // v-开头的指令是帮助我们渲染数据用的        new Vue({            el:"#app",            data:{                greeting:"Hello Vue",            }        })    </script></body></html>v-html:
<!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">    <title>Title</title>    <script src="./static/vue.min.js"></script></head><body>    <div id="app" v-html="greeting"></div>    <script>        // 数据模板引擎:        // v-开头的指令是帮助我们渲染数据用的        new Vue({            el:"#app",            data:{                greeting:"<h1>Hello Vue</h1>",            }        })    </script></body></html>v-for:
<!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">    <title>Title</title>    <script src="./static/vue.min.js"></script></head><body>    <div id="app">        <ul>            <li v-for="aihao in funingbo">{{ aihao }}</li>        </ul>        <ul>            <li v-for="student in students">姓名:{{ student.name }},年龄:{{ student.age }},爱好:{{ student.hobby}}</li>        </ul>    </div>    <script>        // 数据模板引擎:        // v-开头的指令是帮助我们渲染数据用的        new Vue({            el:"#app",            data:{                funingbo:["披黄袍","吃鸡","大鱼大肉","骑士"],                students:[                    {                        name:"张敏聪",                        age:28,                        hobby:"girls",                    },                    {                        name:"徐卫星",                        age:35,                        hobby:"oldboy",                    },                    {                        name:"赵岩",                        age:21,                        hobby:"sao",                    }                ]            }        })    </script></body></html>v-if:
<!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">    <title>Title</title>    <script src="./static/vue.min.js"></script></head><body>    <div id="app">        <div v-if="role == ‘cainingning‘">            <h1>欢迎美女光临~~~</h1>        </div>        <div v-else-if="role == ‘juyingying‘">            <h1>欢迎美女再次光临~~~</h1>        </div>        <div v-else>            <h1>gun</h1>        </div>    </div>    <script>        // 数据模板引擎:        // v-开头的指令是帮助我们渲染数据用的        new Vue({            el:"#app",            data:{                role:"cainingning"            }        })    </script></body></html>v-show:

<!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">    <title>Title</title>    <script src="./static/vue.min.js"></script></head><body>    <div id="app">        <div v-show="isShow">Hello Vue</div>    </div>    <script>        // 数据模板引擎:        // v-开头的指令是帮助我们渲染数据用的        let vm = new Vue({            el:"#app",            data:{                isShow:false            }        })    </script></body></html>v-bind:
<!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">    <title>Title</title>    <script src="./static/vue.min.js"></script>    <style>        .active {            width: 500px;            height: 500px;            background-color: lawngreen;        }    </style></head><body>    <div id="app">        <a v-bind:href="jingdong" >去京东</a>        <div :class="{ active : isActive }"></div>        <div :class="[ isActive ]"></div>    </div>    <script>        // 数据模板引擎:        // v-开头的指令是帮助我们渲染数据用的        let vm = new Vue({            el:"#app",            data:{                jingdong:"https://www.jd.com",                isActive:true,            }        })    </script></body></html>
 

原文地址:https://www.cnblogs.com/zhang-da/p/12172869.html

时间: 2024-08-29 10:24:29

Vue常用指令:的相关文章

vue 常用指令

vue常用指令: 1. v-model   一般用在表单元素   input-->  text  ---> v-model='msg' 2. 循环数组: <li v-for="(value,index) in arr"> {{value}}{{index}} </li> 3.循环json: <li v-for="(value,key) in json"> {{value}} {{key}} </li> 事件

Vue常用指令

vue中常用v-表示指令,下面总结一下常用的指令有哪些: 插入文本:v-text 相当于元素的innerText属性,必须是双标签 插入HMTL:v-html 相当于元素的innerHTML属性 循环:v-for v-for的使用,除了item属性,还有一些其他辅助属性.假设你现在循环的对象名字为students: 如果students是数组,还有index属性,如v-for="(item,index) in students"; 如果students是对象,还有value,key属性

【Vue常用指令】 &#474316;

目录 v-html v-text v-for v-if v-show v-bind v-on v-model 指令修饰符 计算与侦听属性 自定义属性 获取DOM元素 原文: http://blog.gqylpy.com/gqy/276 "@ *** Vue.js官方给自己的定义为==数据模版引擎==,并给出了一套渲染数据的指令.本文将详细介绍Vue.js的常用指令 导入vue.js https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.min

VUE常用指令总结!

<!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <script type="text/javascript" src="https://lib.baomitu.com/vue/2.5.21/vue.js"></script> <title>Document</t

Vue常用的操作指令

前几天给大家介绍了Vue的优点,还有安装步骤,今天给大家再介绍一下Vue常用的操作命令: 常用指令: v-text:用于显示文本 v-html:用于显示HTML 节点里面的内容 v-model:可以绑定 视图上面的数据模型 (数据模型需要在data中 初始化) v-for: 用于 遍历数组 v-for="value in array" ->写在 希望重复的元素上面 v-if v-else v-else-if v-show: 根据条件来显示 v-bind:用于绑定属性 简写 :cl

vue常用的指令

vue常用的指令 <body> <div id="app"> <h1>{{ msg }}</h1>      //数据写入方式 <h2 v-text="msg"></h2>   //v-text写入数据,但是标签名内不能再写入其他的值,因为会被v-text覆盖 <h2 v-once="msg">{{ msg }}</h3>   //v-once本身不能

vue.js介绍,常用指令,事件,以及制作简易留言版

一.vue是什么? 一个mvvm框架(库).和angular类似,比较容易上手.小巧,让我们的代码更加专注于业务逻辑,而不是去关注DOM操作 二.vue和angular之间的区别 vue--简单易学 指令以v-xx 一片html代码配合上json,再new出来vue实例 个人维护项目 适合:移动端项目,小巧 angular--上手难 指令以ng-xxx 所有属性和方法都挂在$scope身上 angular由google维护 适合:pc端项目 共同点:不兼容低版本的IE 三.vue的基本使用 1.

Vue专题-js常用指令

vue.js官方给自己的定为是数据模板引擎,并给出了一套渲染数据的指令.本文详细介绍了vue.js的常用指令. vue.js常用指令 Vue.js使用方式及文本插值 Vue.js 使用了基于 HTML 的模板语法,最简单的使用vue的方式是渲染数据,渲染数据最常见的形式就是使用"Mustache"语法 (双大括号) 的文本插值. 123456789101112131415161718192021222324252627282930 <!DOCTYPE html><ht

vue 快速入门、常用指令(1)

1. vue.js的快速入门使用 1.1 vue.js库的下载 vue.js是目前前端web开发最流行的工具库之一,由尤雨溪在2014年2月发布的. 官方网站 中文:https://cn.vuejs.org/ 英文:https://vuejs.org/ 官方文档:https://cn.vuejs.org/v2/guide/ 1.2 vue.js库的基本使用 在github下载:https://github.com/vuejs/vue/releases 在官网下载地址: https://cn.vu