npm install vue-router --save-dev
<div id="app"> <p> <!-- 使用 router-link 组件来导航. --> <!-- 通过传入 `to` 属性指定在main.js文件设置的别名链接,如/1 --> <!-- <router-link> 默认会被渲染成一个 `<a>` 标签 --> <router-link to="/1">Go to Foo</router-link> </p> <!-- 路由出口 --> <!-- 点击<router-link>的时候指定的页面将渲染在这里 --> <router-view></router-view> </div>
import VueRouter from 'vue-router'
// 1. 定义(路由)组件。
// 加载组件
import Page01 from './max'
Vue.use(VueRouter)
//全局安装路由功能
// 2. 定义路由
// 每个路由应该映射一个组件。
const routes = [
{ path: '/1', component: Page01 }
//前面to指定的地方 path /1
]
// 3. 创建 router 实例,然后传 `routes` 配置
const router = new VueRouter({
routes
})
// 4. 创建和挂载根实例。
// 记得要通过 router 配置参数注入路由,
// 从而让整个应用都有路由功能
new Vue({
el: '#app',
template: '<App/>',
components: { App },
router
})
// 现在,就可以重启试试了!
props: [ 'rimag', 'hyaline', 'levels', 'ohyaline' ],
//HTML
<nv-nav :rimag=mgse :hyaline=ortiy :levels=vels :ohyaline=orctiy></nv-nav>
// 传值用绑定
//JS
data () {
return {
mgse: -20.62,
orctiy: 0,
vels: -1,
ortiy: 0
}
}
//HTML
<nv-nav v-on:child-say="listen"></nv-nav>
//JS
listen: function (mgs, orc, cel, ort) {
this.mgse = mgs
this.orctiy = orc
this.vels = cel
this.ortiy = ort
}
mgs: -20.62, orc: 0, cel: -1, ort: 0
dis: function () {
this.$emit('child-say', this.mgs, this.orc, this.cel, this.ort)
}
<aside @click="dis"></aside>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有