- 创建项目时提示权限不够,保存文件时一直提示输入密码,ERROR: “Failed to save. Insufficient permissions.”,使用如下方法解决,看评论有说不要轻易使用777,但是此方法是目前尝试的最有用的办法
sudo chmod -R 777 filename
- router跳转后有返回按钮的解决方法:
replace
类型: boolean
默认值: false
设置 replace 属性的话,当点击时,会调用 router.replace() 而不是 router.push(),于是导航后不会留下 history 记录。
<router-link :to="{ path: '/abc'}" replace></router-link>
- router带参数传递:
this.$router.replace({
name:‘candyResult’,
query:{
score:this.num
}
});
获取参数的为:this.$route.query.score,非router
-
打包发布
打包时页面地址是添加为本地地址还是线上地址,在vue.config.js文件中修改:
publicPath: process.env.NODE_ENV === ‘development’ ? ‘/’ : ‘http://n.sinaimg.cn/ent/halloween2019/dist/’, -
页面中想添加一个带固定数值的样式
<div class="result-item" :class='["result-"+ candyResult[computedScore].heart_num]'></div>
bind的数据是数组或者对象,需要执行处理才能用
- 样式中可以增加表达式
<span v-for="(obj,index) in candyResult" :key="index" :class="index < candyResult[computedScore].heart_num ? 'heart heart_red' : 'heart'"></span>
-
vue中使用animation.css
1)npm install animate.css --save
2)import animate from 'animate.css
3)<transition enter-active-class="animated fadeIn" leave-active-class="animated fadeOut"></transition>
-
微信分享
getShareConfig() {
let shareLogoUrl = '';
if (shareLogo.indexOf('/promotion') === 0) {
shareLogoUrl = window.location.protocol + '//baoxian.163.com' + shareLogo; // eslint-disable-line
} else {
shareLogoUrl = shareLogo;
}
const linkUrl = window.location.protocol + '//baoxian.163.com/promotion/september/index.html'; // eslint-disable-line
const getUrl = window.location.protocol + '//baoxian.163.com/promotion/h5/wx/wxconfig'; // eslint-disable-line
const datas = {
url: location.href.split('#')[0],
};
axios.get(getUrl, { params: datas }).then((rs) => {
const data = rs.data;
if (data.retcode === 200) {
wx.config({
debug: false,
appId: data.datas.appId,
timestamp: data.datas.timestamp,
nonceStr: data.datas.nonceStr,
signature: data.datas.signature,
jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage'],
});
} else {
console.error(data.retdesc); // eslint-disable-line
}
}).catch((err) => {
console.error(err); // eslint-disable-line
});
wx.ready(function () { // eslint-disable-line
wx.onMenuShareTimeline({
title: '刚刚测试了我的九月运势关键词,快来了解下',
link: linkUrl,
imgUrl: shareLogoUrl,
});
wx.onMenuShareAppMessage({
title: '刚刚测试了我的九月运势关键词,快来了解下',
desc: '九月到了,假期还会远吗?来看看你的本月运势报告',
link: linkUrl,
imgUrl: shareLogoUrl,
});
});
},