
vue
vue
lucky__peng
这个作者很懒,什么都没留下…
展开
-
Vue 路由跳转记住滚动位置,返回时回到上次滚动位置
方法一: 利用Keep-Alive和监听器1.首先在路由中引入需要的模块{ path: ‘/scrollDemo’, name: ‘scrollDemo’, meta: { keepAlive: true // 需要缓存 }, component: resolve => { require([‘../view/scrollDemo.vue’], resolve) } }2.在App.vue中设置缓存组件 <keep-alive> // 缓存组件跳转的页面.转载 2022-04-10 18:23:25 · 2846 阅读 · 1 评论 -
Vue生命周期图示
转载 2022-03-18 23:39:01 · 267 阅读 · 0 评论 -
Vuex中的state,mapState,...mapState
1.state state是什么? 定义:state(vuex) ≈ data (vue) vuex的state和vue的data有很多相似之处,都是用于存储一些数据,或者说状态值.这些值都将被挂载 数据和dom的双向绑定事件,也就是当你改变值的时候可以触发dom的更新. 虽然state和data有很多相似之处,但state在使用的时候一般被挂载到子组件的computed计算属性上,这样有利于state的值发生改变的时候及时响...转载 2022-03-16 19:07:29 · 712 阅读 · 0 评论 -
Vue中使用stylus全局引入不生效的问题
Vue中使用stylus全局引入不生效的问题 问题描述解决方案一解决方案二解决方案三 问题描述 比如说, 一、我们在 App.vue 里面: <style lang="stylus">@import "./style/main.styl"</style> main.styl 里面定...转载 2022-03-05 19:50:04 · 1247 阅读 · 0 评论 -
Vue中this.$router.push(参数) 实现页面跳转
// push参数为字符串this.$router.push('/hello')// 参数为对象 this.$router.push({ path: '/hello' })// 对象中有query属性,相当于发送了一次get请求,请求参数会显示在浏览器地址栏中this.$router.push({ name:'Register', query: { id: this.id } )/* 对象中有params属性,相当于发送了一次post请求,请求参数不会显示在浏览器地址栏中,并且刷新页面之后原创 2021-12-04 21:45:21 · 1296 阅读 · 0 评论 -
You are using the runtime-only build of Vue where the template compiler is not available. Either pre
在升级脚手架到vue-cli3.0版本的时候出现了这个报错:[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.我在这里大概说一下出现这个报错的原因在哪里和解决办法原因v转载 2021-06-06 07:15:03 · 9948 阅读 · 0 评论 -
axios请求添加token的方法
// post请求axios.post('path', {}, { headers: { authorization: `Bearer ${token}`, },});// get请求axios.get('path', { headers: { authorization: `Bearer ${token}`, },});// 统一方式axios.defaults.headers['authorization'] = `Bearer ${token}`;原创 2021-05-11 10:32:01 · 12424 阅读 · 6 评论 -
vue报错Module build failed (from ./node_modules/less-loader/dist/cjs.js): TypeError: this.getOptions
使用vue安装完less和less-loader后报错Module build failed (from ./node_modules/less-loader/dist/cjs.js): TypeError: this.getOptions is not a function这种情况一般是因为安装的版本不对根据提示信息卸载了less-loader,然后安装了less-loader@7.3.0,问题解决如果这个版本也不行的话,可以试试其他的版本...原创 2021-04-22 20:01:52 · 4467 阅读 · 0 评论 -
模仿element-ui封装vue组件库(六)
十二、封装成ui组件库 我们在前面已经将组件全部封装完毕了,现在我们要将组件打包成组件库,上传到github上。由于是模仿element-ui进行的组件封装,所以在发布时也是用element-ui的打包结构。 12.1目录调整 我们新建一个vue项目,并且在根目录创建两个文件夹就packages和examples。 packages:用于存放所有的组件examples:用于进行测试,把src改为exampl...转载 2021-03-27 11:11:25 · 654 阅读 · 0 评论