—————————————-
笔记参考链接
———————————————- 基本语法 —————————————————————————
D:\venus\vue\vue-first
v-bind:指令,令xx和yy属性绑定指令记录
v-model: 取出输入数据实现双向绑定
v-for:循环
v-on:关于事件,调用vue内属性或方法
vue.component:自定义标签模板声明为新标签,可用作传递新数据,标签内数据传递需要通过props声明一个中间变量,并使用v-bind绑定进行值传递。
创建一个vue实例
<script type="text/javascript">var vm = new Vue({el:"#app",/*Model:数据*/data:{message:"hello,vue!"}});</script>
我认为相当于创了一个view model,用作数据model的双向绑定
————————————————- webpack的使用 —————————————————————
D:\venus\vue\packweb
—————————————————
——-模板template:
如果说组件的template内容结构比较简单,可以直接写在template选项中;但是当自定义组件的template内容比较复杂的时候,直接写就不合适了,也容易出错,所以:
对于这种状况Vue给出了自己的解决方案:使用模板,使用Vue的内置template模板来包裹着模板内容
<template id="foreignerName"><!-- <template/>标签内部被包裹着的内容必须有且只有一个根元素,在这里的根元素是ul --><ul><li v-for="item in nameArr">{{item}}</li></ul></template>
这个模板要写在Vue实例的外面,这里template的id属性的值是自定义的,配合js部分用来标识模板内容;但是有一点值得注意, 那就是被template包裹着的内容有且只有一个根元素,在这里是ul元素
JS部分
Vue.component("my-haha",{//如果template模板内容比较复杂,那么就可以这样做template:"#foreignerName",//对应于template中的id属性data:function(){return {nameArr:["Alice","Marry","Athena"]}}})
HTML部分
<div id="container" v-cloak><h3>{{name}}</h3><my-comp></my-comp><!-- 当自定义组件的template模板内容比较复杂的时候 --><my-haha></my-haha></div>
—————————————- vue-router路由设置 ————————————-
配置路由router.js
import Vue from'vue'//1.导入路由插件import Router from 'vue-router'//2.导入上面定义的组件import Content from '../components/Content'import Main from '../components/Main'//3.安装路由Vue.use(Router) ;//4.配置路由export default new Router({routes:[{//路由路径path:'/content',//路由名称name:'content',//跳转到组件component:Content},{//路由路径path:'/main',//路由名称name:'main',//跳转到组件component:Main}]});
[
