vue(二)事件说明
(1)route、routes、router区别
//route
单条路由,局部对象
//routes
拥有多条跳转路由/路由数组的集合,多个局部的对象
//router
路由管理,当项目需要查找某个特定的路由时,router负责到路由器的集合中找到对应的路由,全局的对象
(2)MVVM(通过vue关联视图和模型)
mvc(设计模式)
//model
模型:用一些对象表示数据(变量)
//view
视图:用户看到的界面(html,css)
//controll
控制器:相关的事件交互,业务处理;如何根据视图与用户交互后改变数据(对dom对象的更改,m、v的关联)
(3)生命周期(8个)
1."el"是否存在?
//created 创建
//mounted 渲染
2.渲染模板
3.修改数据、更新数据
4.销毁(通常在组件中使用)
(4)组件
//构建组件
let demo_component = Vue.component("demo_component",{
props:["product"],
template:'<span>{{product.name}}</span>',
data(){ //函数
return{}
},
})
//父组件传值
<demo_component v-for="item in list" :product="item"></demo_component>
//注册:在全局vm内注册
components:{
"demo_component":demo_component
}
!!

浙公网安备 33010602011771号