Vue小结

来源:互联网 发布:网络信息技术服务公司 编辑:程序博客网 时间:2024/05/21 17:53

基础知识

  • new 一个vue对象时可以设置他的属性,其中重要的三个是data,method和watch
  • data代表vue的数据
  • methods代表vue对象的方法
  • filters代表vue对象的数据过滤方法

vue里面的设置通过HTML指令进行关联

其中:
* v-text渲染数据
* v-if 控制显示
* v-for 循环渲染
* v-on 绑定事件,缩写为@
* v-bind 绑定元素属性,缩写为:

index.html 项目入口

<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title>my-first-project</title>  </head>  <body>    <div id="app"></div>    <!-- built files will be auto injected -->  </body></html>

v-text='title' 相当于{{title}}
采用v-text模式的好处是,当一个页面初始状态没有数据时,{{ }}会被当做页面内容显示出来,而v-text不会

原创粉丝点击