- vue中图片路径写法
<img :src="avatorSrc" alt=""> <img :src="avatorSrc2" alt="">
data:function(){ return { avatorSrc:"https://p.ssl.qhimg.com/dmsmty/74_100_100/t01073ee43c0b8459e4.webp", avatorSrc2:require("../../assets/avator.png"),//图片在本地 } }
2.代码中实现路由跳转
<el-menu-item index="1-1" @click="goRouter('/workbench/Needs')">needs</el-menu-item> <el-menu-item index="1-2" @click="goRouter('/workbench/Risk')">risk</el-menu-item> // 路由跳转 Vue.prototype.goRouter = function(path){ this.$router.push(path); }
3.路由拦截设置页面title
// 路由拦截设置页面title router.beforeEach((to,from,next)=>{ if(to.name){ // name 在 路由中配置 window.document.title = to.name; } next(); })