||判斷測試可以
<tabbar v-show="$route.path == '/index' || $route.path == '/storeCenter' || $route.path == '/explore' || $route.path == '/me'" slot="bottom">
<tabbar-item link="/index" :selected="$route.path == '/index'">
<span slot="icon" class="iconfont icon-home"></span>
<span slot="label">首頁</span>
</tabbar-item>
<tabbar-item link="/storeCenter" :selected="$route.path == '/storeCenter'">
<span slot="icon" class="iconfont icon-store"></span>
<span slot="label">門店</span>
</tabbar-item>
<tabbar-item link="/explore" :selected="$route.path == '/explore'">
<span slot="icon" class="iconfont icon-search"></span>
<span slot="label">發(fā)現(xiàn)</span>
</tabbar-item>
<tabbar-item show-dot link="/me" :selected="$route.path == '/me'">
<span slot="icon" class="iconfont icon-wode"></span>
<span slot="label">我的</span>
</tabbar-item>
</tabbar>所有以前的jquery可以實現(xiàn)的功能用vue可以用更有效簡單的方法實現(xiàn)。原理都是一樣的。
正好前幾天我寫一個公司網(wǎng)站用到了導(dǎo)航,下面是我寫的代碼,代碼量很少。
//導(dǎo)航平滑滾動
export default {
name: 'Main',
data() {
return {
msg: 'Welcome to Your Vue.js App'
}
},
components: {
"top": Top,
"official": Official,
"wechat": Wechat,
"payment": Payment,
"category": Category,
"mall": Mall,
"cater": Cater,
"wechat-pay": WechatPay,
"little": Little,
"crm": Crm,
"adv": Adv,
"contact": Contact,
"my-footer": MyFooter,
"loading": Loading
},
computed: {
// 計算屬性的 getter
heightNum: function () {
return 1;
},
position: function () {
let position = this.$store.getters.getPosition;
console.log(position);
let height = this.$refs[position].offsetTop;
let scrollTopValue = this.$refs[position].scrollTop;
this.$store.commit('changeHeight', height);
this.$store.commit('changeScroll', scrollTopValue);
return position;
}
},
mounted: function () {
this.$nextTick(function () {
// Code that will run only after the
// entire view has been rendered
window.addEventListener('scroll', this.changeActive);
this.getOffsetTop();
this.getScrollTop();
})
},
methods: {
greet: function (event) {
// `this` 在方法里指向當(dāng)前 Vue 實例
alert('Hello ' + this.name + '!')
// `event` 是原生 DOM 事件
if (event) {
alert(event.target.tagName)
}
},
scrollTo: function (data) {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
let des = this.$refs[data].offsetTop;
let start = this.$refs[data].scrollTop;
this.moveSlowly(des, start);
},
moveSlowly: function (des, start, time) {
clearInterval(timer);
let speedTime = time || 100;
start || (start = 0);
let distance = des - start;
let speed = distance / speedTime;
let i = 1;
let pos = start;
let timer = setInterval(function () {
if (i == speedTime) {
pos = des;
document.documentElement.scrollTop = document.body.scrollTop = pos;
clearInterval(timer);
} else {
pos = pos + speed;
document.documentElement.scrollTop = document.body.scrollTop = pos;
i++;
}
}, 1)
},
changeActive: function () {
let top = this.$refs.top.offsetTop;
let wechat = this.$refs.wechat.offsetTop;
let category = this.$refs.category.offsetTop;
let contact = this.$refs.contact.offsetTop;
let scrollY = this.scrollY();
this.remove_active();
(scrollY > 0 && scrollY < 500) && (this.$refs.navTop.className = 'active');
(scrollY > wechat && scrollY < (category)) && (this.$refs.navWechat.className = 'active');
(scrollY > category && scrollY < (contact)) && (this.$refs.navCategory.className = 'active');
(scrollY > contact && scrollY < (contact + 500)) && (this.$refs.navContact.className = 'active');
},
remove_active: function () {
this.$refs.navTop.className = '';
this.$refs.navWechat.className = '';
this.$refs.navCategory.className = '';
this.$refs.navContact.className = '';
},
// 滾動條高
scrollY: function () {
return document.documentElement.scrollTop || document.body.scrollTop;
},
getOffsetTop: function () {
let service = this.$refs.service.offsetTop;
let offsetTop = new Object();
offsetTop.mall = this.$refs.mall.offsetTop + service;
offsetTop.cater = this.$refs.cater.offsetTop + service;
offsetTop.wechatpay = this.$refs.wechatpay.offsetTop + service;
offsetTop.little = this.$refs.little.offsetTop + service;
offsetTop.crm = this.$refs.crm.offsetTop + service;
offsetTop.adv = this.$refs.adv.offsetTop + service;
this.$store.commit('changeOffsetTop', offsetTop);
},
getScrollTop: function () {
let scrollTop = window.pageYOffset || document.documentElement.scrollTop;
let scrollTopLen = new Object();
scrollTopLen.mall = this.$refs.mall.scrollTop;
scrollTopLen.cater = this.$refs.cater.scrollTop;
scrollTopLen.wechatpay = this.$refs.wechatpay.scrollTop;
scrollTopLen.little = this.$refs.little.scrollTop;
scrollTopLen.crm = this.$refs.crm.scrollTop;
scrollTopLen.adv = this.$refs.adv.scrollTop;
this.$store.commit('changeScrollTop', scrollTopLen);
}
}
}
</script>你這個寫法本身就有問題吧。。。追求性能之前,請先確保結(jié)果正確
str.substring(0,str.length-2)
你把正則換成 r'_\d+' 就可以了。
.需要加個\.
不能pull和push,建議重新add和commit,再重新pull和commit
可能后端的文件流有問題
已找到解決方案,不能用導(dǎo)航標(biāo)簽,直接用view綁定方法跳轉(zhuǎn)。
那你應(yīng)該使用 context.store,把共享數(shù)據(jù)放到倉庫里
你的 a.js 和 b.js 怎么寫的?
你這種用法:import a from './a'
對應(yīng)的a.js 應(yīng)該有export defaut;
如果沒有 default,
應(yīng)該這樣用:import {a} from './a'
本系列文章所講解內(nèi)容,依賴于https://github.com/icarusion/... 這套架構(gòu)
你的應(yīng)用是8142端口,你用nginx代理就不要用這個端口了啊,換個端口
第一個報錯是說你用的react是開發(fā)環(huán)境的react,真正用在線上環(huán)境打包時可以通過跳過一些步驟來讓打包變得更快。
第二個是打包redux沒設(shè)置node環(huán)境,可以在webpack.config里,在plugin添加
new webpack.DefinePlugin({
'process.env':{
'NODE_ENV': JSON.stringify('production')
}
})
可以解決你的第前兩個報錯
第三個報錯就真的是你的代碼問題了,可能是對數(shù)據(jù)沒有進(jìn)行判斷
store里面vue小寫了。。。蠢比問題
*{
padding: 0;
left: 0;
}
body{
padding-top: 50px;
}
.header{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
background-color: red;
z-index: 10001;
}
.layout{
display: flex;
position: relative;
}
.layout .layout-left{
flex: 0 0 200px;
flex-direction:column;
width: 200px;
color: #fff;
background-color: blue;
}
.layout .layout-right {
background-color: yellow;
overflow-y: auto;
overflow-x: hidden;
position: absolute;
left:215px;
top: 0;
bottom: 0;
right: 0;
margin: auto;
}已解決,,自己進(jìn)入誤區(qū)了;報錯原因?qū)嶋H上就是生產(chǎn)模式下請求的地址沒有設(shè)置好,因為調(diào)用了cnodejs的api,開發(fā)模式下使用了代理;生產(chǎn)模式下需要將請求地址更改為:https://cnodejs.org/api/v1;
具體操作就是在config文件下對dev.env.js和prod.env.js增加默認(rèn)地址前綴:
dev.env.js:
prod.env.js:
在發(fā)送請求時依據(jù)模式調(diào)用:
具體可參考這篇博客:鏈接描述
北大青鳥APTECH成立于1999年。依托北京大學(xué)優(yōu)質(zhì)雄厚的教育資源和背景,秉承“教育改變生活”的發(fā)展理念,致力于培養(yǎng)中國IT技能型緊缺人才,是大數(shù)據(jù)專業(yè)的國家
達(dá)內(nèi)教育集團(tuán)成立于2002年,是一家由留學(xué)海歸創(chuàng)辦的高端職業(yè)教育培訓(xùn)機(jī)構(gòu),是中國一站式人才培養(yǎng)平臺、一站式人才輸送平臺。2014年4月3日在美國成功上市,融資1
北大課工場是北京大學(xué)校辦產(chǎn)業(yè)為響應(yīng)國家深化產(chǎn)教融合/校企合作的政策,積極推進(jìn)“中國制造2025”,實現(xiàn)中華民族偉大復(fù)興的升級產(chǎn)業(yè)鏈。利用北京大學(xué)優(yōu)質(zhì)教育資源及背
博為峰,中國職業(yè)人才培訓(xùn)領(lǐng)域的先行者
曾工作于聯(lián)想擔(dān)任系統(tǒng)開發(fā)工程師,曾在博彥科技股份有限公司擔(dān)任項目經(jīng)理從事移動互聯(lián)網(wǎng)管理及研發(fā)工作,曾創(chuàng)辦藍(lán)懿科技有限責(zé)任公司從事總經(jīng)理職務(wù)負(fù)責(zé)iOS教學(xué)及管理工作。
浪潮集團(tuán)項目經(jīng)理。精通Java與.NET 技術(shù), 熟練的跨平臺面向?qū)ο箝_發(fā)經(jīng)驗,技術(shù)功底深厚。 授課風(fēng)格 授課風(fēng)格清新自然、條理清晰、主次分明、重點難點突出、引人入勝。
精通HTML5和CSS3;Javascript及主流js庫,具有快速界面開發(fā)的能力,對瀏覽器兼容性、前端性能優(yōu)化等有深入理解。精通網(wǎng)頁制作和網(wǎng)頁游戲開發(fā)。
具有10 年的Java 企業(yè)應(yīng)用開發(fā)經(jīng)驗。曾經(jīng)歷任德國Software AG 技術(shù)顧問,美國Dachieve 系統(tǒng)架構(gòu)師,美國AngelEngineers Inc. 系統(tǒng)架構(gòu)師。