HTML:
<p id="zuj">
<router-link to="/home">home</router-link>
<router-link to="/details">details</router-link>
<router-view></router-view>
</p>
<p id="sss">
<p @click="dds()">{{index}}{{message}}</p>
</p>
JS:
vuerouter: function () {
new Vue({
el: '#sss',
data:{
index:1,
message:"sb"
},
methods:{
dds:function () {
alert(1);
this.index=2;
}
},
computed:{
blcontlist:function () {
alert(1)
}
}
});
var Home = {
template: '#sss',
};
var details = {
template: '<p>文章详情页</p>'
};
// 配置路由
var jump = [{
path: '/details',
component: details
},{
path: '/home',
component: Home
}];
// 创建实例
var router = new VueRouter({
routes: jump
});
// 挂载实例
var app = new Vue({
el: '#zuj',
router: router
})
}
.native也试过了不行。