function a(a,b)和function b({a,b})的区别
// 前者在传参的时候可以是单独的传参方式,也可以是键值对的方式 如: a(1,2) Or a({a:1,b:2}) // 后者传参的时候必须以键值对的方式出现 如: b({a:1,b:2})
vue如何动态加载组件
let name = 'component'; let myComponent =() => import('../components/' + name + '.vue'); let route={ name:name, component:myComponent }
2、使用import导入组件,直接将组件赋值给componet
let name = 'component'; let route={ name:name, component :() => import('../components/' + name + '.vue'); }
3、使用require 导入组件,可以获取到组件
let name = 'component'; let myComponent = resolve => require.ensure([], () => resolve(require('../components/' + name + '.vue'))); let route={ name:name, component:myComponent }
4、使用require 导入组件,直接将组件赋值给componet
let name = 'component'; let route={ name:name, component(resolve) { require(['../components/' + name + '.vue'], resolve) } }
vue如何刷新当前页面
定义一个空白的页面
<template></template> <script> export default { name: 'reload', props: {}, beforeCreate() { const { query } = this.$route; const { path } = query; this.$router.replace({ path: path }); }, render(h) { return h(); } } </script>
需要使用的页面
const { fullPath } = this.$route; this.$router.replace({ path: "/redirect", query: { path: fullPath } });