一切福田,不離方寸,從心而覓,感無不通。

Category Archives: Vue

Vue watch 中 this 注意事项

在watch中使用this要注意,不能用箭头函数,否则会出错,例如:

  箭头函数要改为function的形式,如下:

    from:https://blog.csdn.net/liubangbo/article/details/115242420

龙生   07 Apr 2021
View Details

html直接引用vue和element-ui的方法

代码如下所示:

效果如图: 总结 到此这篇关于html直接引用vue和element-ui的方法的文章就介绍到这了,更多相关html引用vue和element-ui内容请搜索脚本之家以前的文章或继续浏览下面的相关文章,希望大家以后多多支持脚本之家!   from:https://www.jb51.net/web/743299.html

龙生   24 Mar 2021
View Details

说说 vue 父子组件加载顺序

面试提问:说说 vue 父子组件加载顺序 这我知道答案 父 beforeCreate 父 created 父 beforeMount 子 beforeCreate 子 created 子 beforeMount 子 mounted 父 mounted 子组件若有 props 的话更新顺序是四步,若无的话两步不触发父亲的钩子。 父 beforeUpdate 子 beforeUpdate 子 updated 父 updated 父组件更新顺序是 父 beforeUpdate 子 deactivated 父 updated 销毁过程是 父 beforeDestroy 子 beforeDestroy 子 destroyed 父 destroyed 再问,如果有多个子组件呢?我不太能确定。 加载多个子元素 回头写了一个简单的vue视图,父调用子,以下代码复制可用。

  控制台打印结果如下

  能得出结论,第一个子元素在 beforeMount 后不会直接 mounted,而是进入下一个子元素的 beforCreate。   from:https://www.cnblogs.com/everlose/p/12538472.html

龙生   15 Mar 2021
View Details

npm ERR! Unexpected end of JSON input while parsing near

You are trying to create a new angular, react, vue app, and you end up with an error message saying: npm ERR! Unexpected end of JSON input while parsing near There’s a high chance that your npm cache been damaged. Try:

  If you are a windows user, try deleting all files in this folder:

  Then…

  If that doesn’t work, try updating to the lastest (understand the risks)

  I hope this helps!   from:https://dev.to/rishiabee/npm-err-unexpected-end-of-json-input-while-parsing-near-743

龙生   22 Jan 2021
View Details

Vue 魔法师 —— 将 API “类化”

前言 【类】和【接口】是 JavaScript 未来的方向,我们的 API 调用也将如此,朝着这个方向和业务模块同步分类、同步升级。本文讲的正是 —— Vue 魔法师,如何将 API “类化”? 万物皆模块,万物可归类。闲言少叙,直接正题。 分类 API 环境: Vue2+ 或 Vue3+ 咱这里直接 VueCLI 迅速快捷构建

得到如下目录

  然后新建文件 api.js 如下,

  基础类 API 我们先创建一个基础类如下:

  baseUrl:设置请求根路径; resource:来源; getUrl:获取链接函数,包含 baseUrl、resource、id; handleErrors:处理错误函数; 只读类 API 然后,我们再创建一个子类:包含 fetch、get 只读方法。

  fetch:获取数据; get:通过 id 获取数据; 写入类 API 接着,我们再创建一个包含可读写方法的子类:post、put、delete

  post:创建数据; put:更新数据; delete:删除数据; 继承 让我们看看两个简单的继承示例:

 

  【UsersApiService 类】继承了只读类 API —— ReadOnlyApiService,可以使用 fetch、get 两种方法。而 【PostsApiService 类】继承了读写类 API —— ModelApiService,可以使用 fetch、get、post、put、delete 五种方法。 我们也可以根据业务来写继承 API 类:

  导出 我们在 api.js 导出这些 […]

龙生   22 Jan 2021
View Details
1 3 4