{{ title }}

插值渲染

单字段插值

time: {{ time }}
msg: {{ msg }}
time: {{ time }}
msg: {{ msg }}

多字段插值

{{ msg }} {{ title }} {{ aas }}
{{ time }} {{ msg }} {{ time }}

对字段解构插值

test: {{ test }}
test: {{ test }}
test.count: {{ test.count }}
test.count: {{ test.count }}
list[0]: {{ list[0] }}

插值表达式

{{ test.count + 5 - 1 }}

:动态属性绑定

style:
style动态绑定
class类名动态绑定
其他属性绑定

双向绑定 & 数据响应式

点击事件(支持所有原生dom事件绑定)

生命周期(查看后台打印信息)

  1. beforeCreate
  2. created
  3. beforeMount
  4. mounted

watch 函数

效果输入框改值,看控制台打印

        watch: {
        msg(oldVal, newVal) {
        console.log('msg oldVal:', oldVal)
        console.log('msg newVal:', newVal)
        },
        },
      

v-for 列表渲染

list: {{JSON.stringify(list)}}
  1. {{ item }}

v-show

show: {{ show }}
测试文字

html source code

javascript source code