sbfkcel / towxml

微信小程序HTML、Markdown渲染库
https://github.com/sbfkcel/towxml/wiki
2.47k stars 313 forks source link

wepy2 中 md.use错误 e.apply is not a function #175

Open mrYuandq opened 3 years ago

mrYuandq commented 3 years ago

环境:

wepy2 + towxml3

问题:

image

定位:

经过拆解看到问题是 md.use 引起的,如果把这句注释就可以使用了,但相应的 解析扩展,自定义组件 就不能用了。

image

配置项:

app.vue 中添加 towxml 引用

wepy.app({
  towxml: require('@/towxml/index'),
  ...
})

页面中 引用 towxml 组件和使用 app 中的towxml生成markdown字符串

wepy.page({
    ...
    this.article = {
      ...data,
      content: this.$app.$options.towxml(data.content, 'markdown', {
        theme: 'light',
        events: {
          tap: (e) => {
            console.log('tap', e)
          },
        },
      }),
    }
    ...
})

求解

markdown.js 是编译过的代码,麻烦看一下是什么问题〜 markdown.js 是编译过的代码,麻烦看一下是什么问题〜 markdown.js 是编译过的代码,麻烦看一下是什么问题〜

sbfkcel commented 3 years ago

image 先留 一个,逐个添加看一下呢。帮排除下是哪个插件出了问题。

mrYuandq commented 3 years ago

这个判断是取的 非(!) 吧,之前已经看过了,.use 的第一个就错 sub,感觉是像是 .use 这个方法的问题,不是插件的问题

这个是 config.js

image

image

如果把 sub 暂时注释掉

image

sbfkcel commented 3 years ago

把towxml先不参与编译呢?

mrYuandq commented 3 years ago

先不参与编译? app.js 中引用 require('@/towxml/index') 这个就会出这个错

sbfkcel commented 3 years ago

能否丢一个简单的DEMO附件给我。我排查一下。

mrYuandq commented 3 years ago

附上 简单DEMO

wepy-towxml-demo.zip

sbfkcel commented 3 years ago

拉取最新代码,再构建试一下。