NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.37k stars 4.78k forks source link

小程序wxparser插件模板错误 #7574

Open zhuxianguo opened 4 years ago

zhuxianguo commented 4 years ago

相关平台

微信小程序

小程序基础库: 2.12.1 使用框架: React

复现步骤

//app.config

export default {
  plugins: {
    "wxparserPlugin": {
      "version": "0.3.0",
      "provider": "wx9d4d4ffa781ff3ac"
    }
  },
  pages: [
    'pages/index/index',
    'pages/test/index',
  ],
  window: {
    backgroundTextStyle: 'light',
    navigationBarBackgroundColor: '#fff',
    navigationBarTitleText: 'WeChat',
    navigationBarTextStyle: 'black'
  },
  tabBar: {
    position: 'bottom',
    color: "#9b9b9b",
    selectedColor: "#FF423E",
    backgroundColor: "#ffffff",
    borderStyle: "black",
    list: [
      {
        pagePath: 'pages/index/index',
        text: 'index',
      },
      {
        pagePath: 'pages/test/index',
        text: 'test',
      },
    ],
  }
}

//pages/index/index.jsx

import React, { Component } from 'react'
import { View } from '@tarojs/components'

class Index extends Component {
  constructor(props){
    super(props)
  }
  render () {
    return (
      <View>
        <wxparser rich-text="hello" />
      </View>
    )
  }
}
export default Index

//pages/index/index.config.js

export default {
  navigationBarTitleText: '首页',
  usingComponents: {
    "wxparser": "plugin://wxparserPlugin/wxparser"
  }
}

期望结果

期望能正常解析

实际结果

可解析出标记,但是无内容

环境信息

  Taro CLI 3.0.8 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 10.18.1 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.19.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.14.5 - C:\Program Files\nodejs\npm.CMD
zhuxianguo commented 4 years ago

弄了一个临时测试demo https://github.com/zhuxianguo/taro-next-plugin-test

zhuxianguo commented 4 years ago

感觉找到原因了,taro3生成的插件模板不能正确传值 taro3生成的模板

<template name="tmpl_1_wxparser">
  <wxparser  id="{{i.uid}}">
    <block wx:for="{{i.cn}}" wx:key="uid">
      <template is="tmpl_2_container" data="{{i:item,l:l}}" />
    </block>
  </wxparser>
</template>

实际应该通过属性来进行传值才能正常解析

<template name="tmpl_1_wxparser">
  <wxparser rich-text="{{i.richText}}"/>
</template>

但是咋改这个模板呢?