watch: {
'$route' (to, from) {
if (['create'].indexOf(to.name) > -1) {
this.$nextTick(() => {
switch (to.name) {
case 'issueDetail':
this.$refs['issues'].classList.add('router-link-active')
break;
case 'resdetail':
this.$refs['resources'].classList.add('router-link-active')
break;
// 這樣寫能夠包含多個條件
case 'create':case 'detail':case 'history': case 'modify': case 'publish':
this.$refs['applist'].classList.add('router-link-active')
break;
}
})
} else {
this.$nextTick(() => {
this.$refs['issues'].classList.remove('router-link-active')
this.$refs['resources'].classList.remove('router-link-active')
this.$refs['applist'].classList.remove('router-link-active')
})
}
}
}
3. ajax請求參數時須要寫contentType
爲何會說在請求ajax時帶上contentType,由於有時不會請求的參數體就變成這樣:(以下圖)
圖一:
很明顯就不同,接下來放一張正常時的請求體圖片:(以下圖)
圖二:
圖一那樣子請求不加入contenType也是能夠請求成功的,可是我以爲那個樣子是不合理的,因此在ajax請求中攜帶了
contentType:"application/json;charset=UTF-8"