Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信小程序组件wxparse,taro convert转义之后界面渲染空白 #2199

Closed
luodanyalian opened this issue Feb 18, 2019 · 11 comments
Closed
Assignees

Comments

@luodanyalian
Copy link

微信小程序组件wxparse,taro convert转义之后界面渲染空白
源码:

<!--index.wxml-->
<import src="../../components/wxParse/wxParse.wxml"/>
<view class="container">
      <!-- <selectbar selectBarData="{{myOrder}}" bind:callback="_gotoMyOrderPage"></selectbar> -->

      <template is="wxParse0" data="{{wxParseData:tabContent.nodes}}"/>
</view>

taro convert 转义之后:

import { Block, View, Video, Image, Text, Button } from '@tarojs/components'
import Taro from '@tarojs/taro'
import withWeapp from '@tarojs/with-weapp'
//index.js
import { wxParse } from '../../components/wxParse/wxParse.js'
//获取应用实例
import TaroParsezaTmpl from '../../imports/TaroParsezaTmpl.js'
import TaroParsezzTmpl from '../../imports/TaroParsezzTmpl.js'
import TaroParseiTmpl from '../../imports/TaroParseiTmpl.js'
import TaroParsehTmpl from '../../imports/TaroParsehTmpl.js'
import TaroParsegTmpl from '../../imports/TaroParsegTmpl.js'
import TaroParsefTmpl from '../../imports/TaroParsefTmpl.js'
import TaroParseeTmpl from '../../imports/TaroParseeTmpl.js'
import TaroParsedTmpl from '../../imports/TaroParsedTmpl.js'
import TaroParsecTmpl from '../../imports/TaroParsecTmpl.js'
import TaroParsebTmpl from '../../imports/TaroParsebTmpl.js'
import TaroParsezTmpl from '../../imports/TaroParsezTmpl.js'
import TaroParseTmpl from '../../imports/TaroParseTmpl.js'
import TaroParseBrTmpl from '../../imports/TaroParseBrTmpl.js'
import TaroEmojiViewTmpl from '../../imports/TaroEmojiViewTmpl.js'
import TaroParseImgTmpl from '../../imports/TaroParseImgTmpl.js'
import TaroParseVideoTmpl from '../../imports/TaroParseVideoTmpl.js'
import './index.scss'
const app = Taro.getApp()

@withWeapp('Page')
class _C extends Taro.Component {
  state = {}

  componentWillMount() {
    app.wechatLogin(() => {
      //此处是处理用户登录成功之后的业务逻辑
    })
    const tabContent = `<p style="color:red;">我是HTML</p>`
    wxParse('tabContent', 'html', tabContent, this, 0)
  }

  config = {}

  render() {
    const { tabContent: tabContent } = this.state
    return (
      <Block>
        {/* index.wxml */}
        <View className="container">
          <TaroParsezTmpl
            data={{
              wxParseData: tabContent.nodes
            }}
          />
        </View>
      </Block>
    )
  }
}

export default _C

👽 Taro v1.2.13
Taro CLI 1.2.13 environment info:
System:
OS: macOS 10.14
Shell: 5.3 - /bin/zsh
Binaries:
Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
Yarn: 1.9.4 - ~/.nvm/versions/node/v8.11.3/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.11.3/bin/npm

@taro-bot
Copy link

taro-bot bot commented Feb 18, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@yuche
Copy link
Contributor

yuche commented Feb 18, 2019

@luodanyalian
Copy link
Author

@yuche yuche added the taroize label Feb 18, 2019
@yuche yuche self-assigned this Feb 18, 2019
@yuche
Copy link
Contributor

yuche commented Feb 18, 2019

经调研发现是微信好像突然又不支持自引用自定义组件了……

@luodanyalian
Copy link
Author

不支持么?我看源码引用wxparse没有问题的。现在经过特殊处理之后是好了吗?

@yuche
Copy link
Contributor

yuche commented Feb 19, 2019

编译出来的代码没啥问题。现在问题是 wxparse 的模板原来是 wxparse0 引用 wxparse1,wxparse2 引用 wxparse3 这样一直循环下去,直到 wxparse12 不存在,也就是说嵌套超过 12 层,原本的 wxparse 就会崩掉。

文档让你改的代码就是让 模板 wxparse0 (本来是模板,但已经编译成微信自定义组件)引用自身,这样避免了那个问题,但会产生一个自引用组件,而这个自引用组件又是在循环中使用的。我尝试了一下如果保持原来 wxparse 引用方式是可以的,但这样又会有原来 wxparse 的问题,并且由于 wxparse12 因为不存在会造成引用不存在错误。

现在还不清楚微信的哪块机制崩掉了才导致原来的自引用无效,今天还得再调研一下。

@luodanyalian
Copy link
Author

明白了,多谢

@yuche yuche closed this as completed in 31b16b6 Feb 19, 2019
@yuche
Copy link
Contributor

yuche commented Feb 19, 2019

确认了是微信更新之后对自定义组件自引用支持有问题的缘故导致 wxparse 崩掉,现在修改源码的方式有变:
https://github.com/NervJS/taro/blob/master/docs/taroize.md

基本就是原来是 wxparse0 引用 wxparse0 自己,现在是 wxparse0 引用 wxparse1,wxparse1 引用 wxparse0,修改了之后配合新的版本应该可用了:

image

@pan289091315
Copy link

@yuche 按照你说的这样改还是报Can't resolve './TaroParseBrTmpl'

@pan289091315
Copy link

@yuche 已经按照文档修改了

@dinghangxing
Copy link

Module not found: Can't resolve './TaroParseBrTmpl' in 'E:\project\iqudong\pupuyu\taroConvert.temp\imports'

按文档修改了wxParse ,请大佬指点 @yuche

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants