jsx注册全局公共组件,引用其他组件报错,提示其他组件未注册

背景:

vueCli4中使用jsx方式注册一个全局公共组件,结果引用了elementUI组件报错

render(h) {
    let html = `<el-tag>标签</el-tag>`
    const com = Vue.extend({
      template: `<div class="articleContent">${html}</div>`
    })
    return h(com, {})
  }

vue.esm.js?a026:628 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option.

在main.js中我确定一定以及肯定是引入了elementUI

  • 所以猜测可能问题是render上下文不一样,目前也没有其他好办法,只能将elementUI在这个地方再注册一遍,等我进化了在回头想其他更好的解决办法吧
<script>

import Vue from "vue/dist/vue.esm.js"
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css';
Vue.use(ElementUI);


export default {
  name: 'ArticleContent',
  props: {
    html: String
  },
  render(h) {
    let html = `<el-tag>标签</el-tag>`
    const com = Vue.extend({
      template: `<div class="articleContent">${html}</div>`
    })
    return h(com, {})
  }
};
</script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值