码迷,mamicode.com
首页 > 其他好文 > 详细

01-路由跳转 安装less this.$router.replace(path);

时间:2019-11-17 19:25:40      阅读:67      评论:0      收藏:0      [点我收藏+]

标签:play   main   文件   解决方法   handler   ade   lex   create   pos   

2==解决vue2.0里面控制台包的一些语法错误。

https://www.jianshu.com/p/5e0a1541418b

在build==>webpack.base.conf.j
下注释掉 ...(config.dev.useEslint ? [createLintingRule()] : []),
rules: [
// ...(config.dev.useEslint ? [createLintingRule()] : []),
{
test: /\.vue$/,
loader: "vue-loader",
options: vueLoaderConfig
},

 

 

 

3==>
vue使用less报错的解决方法 安装less less-loader
cnpm install less less-loader --save-dev


4.1
app.vue是所有XXX.vue文件的根文件
所以webapp,的底部通常是在这里配置

 

 

 


4==》h5的新增
<header>标题</header>
<main>主题内容</main>
<footer>固定的底部内容</footer>
所以底部通常不使用footer


5==>元素在最底部水平排列
<div class="myfooterbox">
<div>外卖</div>
<div>搜索</div>
<div>订单</div>
<div>我的</div>
</div>

.myfooterbox {
width: 100%;
display: flex;
justify-content: space-between;
position: fixed;
bottom: 0;
left: 0;
}
ps==>如果元素的宽度是自身的宽度。
justify-content: space-between;可能是是没有效果的。

 

 

6==》点击路由跳转
this.$router.push({ path: "/search" });

 

 

7==》给当前点击的元素添加背景色 同样是借助三目运算 如果是true 添加某一个类

.on {
background: pink;
}

<div @click="handlersell" :class="{ on: ‘/‘ === $route.path }">外卖</div>
<div @click="handlersearch" :class="{ on: ‘/search‘ === $route.path }">搜索</div>

 

 


8==》 路由跳转
<div @click="handlersell" :class="{ on: ‘/‘ === $route.path }">外卖</div>
<div @click="handlersearch" :class="{ on: ‘/search‘ === $route.path }">搜所 </div>

methods: {
handlersell() {
this.$router.push({ path: "/" });
},
handlersearch() {
this.$router.push({ path: "/search" });
},
}

优化后 使用了replace
<div @click="handlergo(‘/‘)" :class="{ on: ‘/‘ === $route.path }">外卖</div>
<div @click="handlergo(‘/search‘)" :class="{ on: ‘/search‘ === $route.path }" >搜索</div>

handlergo(path) {
this.$router.replace(path);
}


11ok

01-路由跳转 安装less this.$router.replace(path);

标签:play   main   文件   解决方法   handler   ade   lex   create   pos   

原文地址:https://www.cnblogs.com/IwishIcould/p/11877572.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!