修复decodeURIComponent报错

This commit is contained in:
yi-ge 2019-03-23 22:11:40 +08:00
parent 3e169a7493
commit 58e36e8c17

View File

@ -26,10 +26,10 @@ div
nuxt-link(:to="Articels.last ? '/post/' + Articels.last.ID : ''") nuxt-link(:to="Articels.last ? '/post/' + Articels.last.ID : ''")
.btnFooter.btnPrevt(:style="'color: ' + (Articels.last ? '#333' : '#ccc')") .btnFooter.btnPrevt(:style="'color: ' + (Articels.last ? '#333' : '#ccc')")
Icon(:icon="['fas', 'chevron-left']") Icon(:icon="['fas', 'chevron-left']")
|   上一篇 {{ Articels.last ? '(' + decodeURIComponent(Articels.last.post_name) + ')' : ''}} |   上一篇 {{ Articels.last ? '(' + decodeTitle(Articels.last.post_name) + ')' : ''}}
nuxt-link(:to="Articels.next ? '/post/' + Articels.next.ID : ''") nuxt-link(:to="Articels.next ? '/post/' + Articels.next.ID : ''")
.btnFooter.btnNext(:style="'color: ' + (Articels.next ? '#333' : '#ccc')") .btnFooter.btnNext(:style="'color: ' + (Articels.next ? '#333' : '#ccc')")
| 下一篇 {{ Articels.next ? '(' + decodeURIComponent(Articels.next.post_name) + ')' : ''}}   | 下一篇 {{ Articels.next ? '(' + decodeTitle(Articels.next.post_name) + ')' : ''}}  
Icon(:icon="['fas', 'chevron-right']") Icon(:icon="['fas', 'chevron-right']")
.comment .comment
@ -135,6 +135,18 @@ export default {
} }
}, },
methods: { methods: {
decodeTitle(name) {
try {
// return decodeURIComponent(name.replace(/[%]/g, function (m) {
// return '%' + m.charCodeAt(0).toString(16)
// // Basically changes "%" to "%25".
// }))
return decodeURI(escape(name))
} catch (err) {
console.log(err)
return name
}
},
articelRightTocClick() { articelRightTocClick() {
const windowWidth = window.innerWidth || document.documentElement.clientWidth const windowWidth = window.innerWidth || document.documentElement.clientWidth
if (windowWidth < 768) { if (windowWidth < 768) {