8.6总结
遇到问题
1.阻止路由重复报错
//路由重复时阻止报错
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
2.引入sweetalert2
npm install sweetalert2@11.0.18 --save
src/plugins/vue-sweetalert2
import swal from 'sweetalert2'
export default {
install: (Vue) => {
// 添加全局方法
Vue.swal = swal
// 添加实例方法
Vue.prototype.$swal = swal
}
}
main.js
import VueSweetalert2 from './plugins/vue-sweetalert2'
Vue.use(VueSweetalert2);
import 'sweetalert2/dist/sweetalert2.min.css';
3.a-input的max-length报错
Invalid prop: type check failed for prop “maxLength”. Expected Number with value 30, got String with value “30”.
把<a-input max-length="30" >改成
<a-input :max-length="30" >