
获得徽章 0
赞了这篇文章
v-on:$listeners v-on:testFn=""
1、如果 listeners 中也有 testFn 绑定方法,则子组件中emit('testFn'),会先后调用当前组件及父组件中的方法,
2、联想到mixins,当前组件中同名方法会覆盖掉混合对象中的该方法,生命周期方法会都执行,先执行混合中的再执行当前对象
1、如果 listeners 中也有 testFn 绑定方法,则子组件中emit('testFn'),会先后调用当前组件及父组件中的方法,
2、联想到mixins,当前组件中同名方法会覆盖掉混合对象中的该方法,生命周期方法会都执行,先执行混合中的再执行当前对象
评论
点赞
Error: Redirected when going from "X" to "X" via a navigation guard.
---------------------解决方案------------------------------
原因:
V3.1.0版本里面新增功能:push和replace方法会返回一个promise, 你可能在控制台看到未捕获的异常。
解决:
在你的routers.js中,引入Router后,对Router原型链上的push、replace方法进行重写,这样就不用每次调用方法都要加上catch。
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
或者降级vue
参考链接:如下
---------------------解决方案------------------------------
原因:
V3.1.0版本里面新增功能:push和replace方法会返回一个promise, 你可能在控制台看到未捕获的异常。
解决:
在你的routers.js中,引入Router后,对Router原型链上的push、replace方法进行重写,这样就不用每次调用方法都要加上catch。
import Router from 'vue-router'
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}
或者降级vue
参考链接:如下
展开
评论
点赞
赞了这篇文章
有人知道我在干嘛吗?哈哈哈哈哈哈
let obj = '[{ "name":"runoob", "alexa":10000, "site":"m.runoob.com", "a": 1, "75": "555"}, { "name":"dfbxb", "alexa":3000, "site":"fdttrdom", "a": 1, "75": "5585"}]'
let [indexArr0, indexArr1] = [obj.indexOf("{"), obj.indexOf("}")]
let head = obj.substring(indexArr0+1, indexArr1).replace(/\s*/g,"")
let arr = head.split(",").map(item => item.replace(/\"/g,""))
arr.map(item => {
const [k, v] = item.split(":")
const tmp = {}
tmp[k] = v
return tmp
})
let obj = '[{ "name":"runoob", "alexa":10000, "site":"m.runoob.com", "a": 1, "75": "555"}, { "name":"dfbxb", "alexa":3000, "site":"fdttrdom", "a": 1, "75": "5585"}]'
let [indexArr0, indexArr1] = [obj.indexOf("{"), obj.indexOf("}")]
let head = obj.substring(indexArr0+1, indexArr1).replace(/\s*/g,"")
let arr = head.split(",").map(item => item.replace(/\"/g,""))
arr.map(item => {
const [k, v] = item.split(":")
const tmp = {}
tmp[k] = v
return tmp
})
展开
2
点赞