1、active-class是那个组件的属性?嵌套路由怎么定义?
答:vue-router模块的router-link组件。
2、怎么定义vue-router的动态路由?怎么获取传过来的动态参数?
答:在router目录下的文件中,对path属性加上:/d 使用router对象的
3、vue-router有哪几种导航钩子?
答:3种
第1种、全局钩子 (to,from,next) 作用跳转前进行判断拦截
beforeEach
beforeResolve
afterEach
-
//定义一个路由
-
const router = new VueRouter({ ... })
-
-
// 点击导航前调用
-
((to, from, next) => {
-
// ...
-
})
-
// 点击导航后调用
-
(route => {
-
// ...
-
})
第二种:组件内的钩子
beforeRouteEnter
beforeRouteUpdate (2.2 新增)
beforeRouteLeave
-
let fromPath = '';
-
export default{
-
beforeRouteEnter (to, from, next) {
-
// 在渲染该组件的对应路由被 confirm 前调用
-
// 不!能!获取组件实例 `this`
-
// 因为当钩子执行前,组件实例还没被创建
-
fromPath = ;
-
next();
-
},
-
}
第三种:单独路由独享组件
beforeEnter
-
const router = new VueRouter({
-
routes: [
-
{
-
path: '/foo',
-
component: Foo,
-
beforeEnter: (to, from, next) => {
-
// ...
-
},
-
beforeEnter: (route) => {
-
// ...
-
}
-
}
-
]
-
});
4、scss是什么?安装使用的步骤是?有哪几大特性?
答:预处理css、把css当前函数编写,定义变量、嵌套;
先装css-loader、node-loader、sass-loader等加载器模块,
在webpack-配置文件中加多一个拓展:extenstion,
再加多一个模块:module里面test、loader
5、scss是什么?中的安装使用步骤是?有哪几大特性?
-
答:css的预编译。
-
使用步骤:
-
第一步:用npm 下三个loader(sass-loader、css-loader、node-sass)
-
第二步:在build目录找到,在那个extends属性中加一个拓展.scss
-
第三步:还是在同一个文件,配置一个module属性
-
第四步:然后在组件的style标签加上lang属性 ,例如:lang=”scss”
-
有哪几大特性:
-
1、可以用变量,例如($变量名称=值);
-
2、可以用混合器,例如()
-
3、可以嵌套