![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前端框架
vue react angular
前端小安
这个作者很懒,什么都没留下…
展开
-
vue中第三方css样式或者自定义样式在 scoped 下失效
::v-deep xxxxxx {}在 less 或者 scss 中>>> xxxxx {}原创 2021-04-15 13:51:34 · 293 阅读 · 0 评论 -
vue父组件调用子组件方法,子组件调用父组件
通过组件的emit、emit、emit、on 方法// 在父组件,首先使用ref标记组件<children ref="children"></children>;// 触发子组件中注册的事件this.$refs.children.$emit("test");// 在子组件,绑定事件,在调用事件之前要注册好this.$on("test", (val) => { this.func(val); // 你要触发的子组件中的函数});通过 ref 直接调用子组件原创 2021-04-14 10:02:03 · 116 阅读 · 0 评论 -
vue插件plugins的几种写法
Vue.js 的插件应该暴露一个 install 方法。这个方法的第一个参数是 Vue 构造器,第二个参数是一个可选的选项对象MyPlugin.install = function (Vue, options) { // 1. 添加全局方法或 property Vue.myGlobalMethod = function () { // 逻辑... } // 2. 添加全局资源 Vue.directive('my-directive', { bind (el, bi.原创 2021-04-13 13:35:17 · 1087 阅读 · 0 评论 -
vue中如何处理图片加载失败
利用img的onerror事件第一种<img :src="avatar || ''" :onerror="errorImg">// 这里面src必须保证是个空值要不然不触发 onerrordata() { return { errorImg: 'this.src=\'//xxxxxxx\'' }}// xxxxxx是地址第二种<img :src="avatar || ''" @error="test">methods: { test(e.原创 2021-04-12 16:05:20 · 533 阅读 · 0 评论