vuejs v-for指令
原创 2017-02-07 10:52:22
498阅读
看一个例子: <html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <ul> <li v-for="(item, index)
转载 2020-02-17 10:29:00
131阅读
2评论
<div id='root'> <div v-if='show'>helle world</div> <button @click='handleClick'>toggle</button> </div> <script> new Vue({ el:'#root', data:{ show:true
转载 2018-09-04 06:47:00
196阅读
2评论
<!DOCTYPE html><html lang="en"><head> <meta charset="
原创 2022-11-18 19:14:19
1905阅读
咯 直接看代码首先 先说一下 把vue构造器
原创 2022-10-17 20:08:33
41阅读
前言最近在开发中需要用到动态设置ref的内容,摸索了很久终于弄明白了要怎么实现。1.绑定指定某一个组件1.1、例如:这是一个编辑器组件,在这里把它的ref设置为myeditor<fcEditor ref="myeditor"></fcEditor>1.2、在代码中通过myeditor名称获取这个组件this.$refs.myeditor;2.使用:ref动态设置组件名称2.
原创 2022-09-27 11:56:00
978阅读
<div id='root'> <ul> <todo-item></todo-item> </ul> </div> <script> Vue.component('todo-item',{ template:'<li>item</li>' }) </script> 全局组件:上面这种组件叫做全局组件
转载 2018-09-04 21:46:00
232阅读
2评论
场景,点击某个按钮,两个子组件交替显示 <div id='root'> <child-one v-if='type "child-one"'></child-one> <child-two v-if='type "child-two"'></child-two> <button @click='ha
转载 2018-09-19 06:51:00
126阅读
2评论
Vue学习(二)- v-forv-for就相当于程序语言中的for一样,可以遍历一个Array、Objec
原创 2022-11-09 18:25:56
139阅读
Title {{food.name}}:¥{{food.discount ? food.price*food.discount : food.price }} var app = new Vue({ el:"#app", data:{ //...
原创 2021-05-20 19:56:28
175阅读
内容来自于网络: Vue for v-for 2.x版本:v-for="(item,index) in items"index即索引值。 理解v-for="( item, index) in item次渲染元素或模板块。在v-for=
转载 6月前
11阅读
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> {{message}} <ul> <li v-for="item in ...
转载 2021-06-21 01:13:00
185阅读
2评论
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <div id="app"> <ul> <li v-for="p in personArr">{{p} ...
转载 2021-08-17 18:24:00
352阅读
2评论
<div id="app"> <ul> <li v-for="(value, key, index) in info"> {{value}} - {{key}} - {{index}}</li> </ul> <ul> <li v-for="item in info"> {{item}}</li> </ul></div>.
原创 2022-06-27 11:15:55
171阅读
前言vif 指令用于条件性地渲染一块内容。这块内容只会在指令的表达式返回 true值的时候被渲染vfor 指令基于一个数组来渲染一个列表。vfor 指令需要使用 iteminitems 形式的特殊语法,其中 items 是源数据数组或者对象,而 item 则是被迭代的数组元素的别名在 vfor 的时候,建议设置key值,并且保证每个key值是独一无二的,这便于diff算法进行优化两者在用法上<Mo
原创 2022-12-21 20:58:40
215阅读
官网有说v-if与v-for不要放在一起用因为v-if的优先级大,获取不到v-for的值所以
原创 2022-08-19 11:31:38
144阅读
在自定义组件里,你可以像任何普通元素一样用 v-for 。<my-component v-for="item in items"></my-component>然而他不能自动传递数据到组件里,因为组件有自己独立的作用域。为了传递迭代数据到组件里,我们要用 props :HTML:<my-component v-for="(item, index) in ...
原创 2021-07-07 13:48:53
120阅读
在自定义组件里,你可以像任何普通元素一样用 v-for 。<my-component v-for="item in items"></my-component>然而他不能自动传递数据到组件里,因为组件有自己独立的作用域。为了传递迭代数据到组件里,我们要用 props :HTML:<my-component v-for="(item, index) in ...
原创 2022-03-24 11:10:55
230阅读
<body> <div id="example"> <father></father> </div> </body> <script> Vue.component('child', { // 声明 props props: ['messa
原创 2021-08-27 15:27:02
242阅读
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdn.staticfile.org/vue/2.6.12/vue.min.js"></script> </head> <body> <div id=" ...
转载 2021-06-13 23:53:00
101阅读
2评论
  • 1
  • 2
  • 3
  • 4
  • 5