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

Taro 中引入 Parse 渲染报错 ./base.wxml Template tmpl_5_parser not found. #7550

Closed
drunkWindy opened this issue Sep 8, 2020 · 7 comments
Labels
F-react Framework - React T-jd Target - 编译到京东小程序 V-3 Version - 3.x

Comments

@drunkWindy
Copy link

相关平台

京东小程序

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

复现步骤

1、组件引入
config = {
usingComponents: {
parser: '@/utils/Parser/index' // 引入插件包
}
}
2、render () {
return (



)
}

期望结果

渲染富文本

实际结果

VM1098:1 ./base.wxml
Template tmpl_5_parser not found.
2115 |
2116 |

2117 |
| ^
2118 |
2119 |
2120 |

环境信息

Taro CLI 3.0.8 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.4 - C:\Users\PC\AppData\Roaming\npm\yarn.CMD
      npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD

@taro-bot2 taro-bot2 bot added F-react Framework - React T-jd Target - 编译到京东小程序 V-3 Version - 3.x labels Sep 8, 2020
@luckyadam
Copy link
Member

能否给个 demo 看下

@JX-Zhuang
Copy link

遇到同样的问题,按照官方文档引入echarts-for-weixin,提示 WXMLRT_$gwx:./base.wxml:template:425:16: Template tmpl_0_ec-canvas not found.
参考链接:https://github.com/NervJS/taro-sample-weapp/blob/master/src/pages/echarts/echarts.js
"@tarojs/cli": "3.0.9"
demo

//  page/echarts/echarts.tsx
import React from 'react';
import { View } from '@tarojs/components'
import * as echarts from '../../components/ec-canvas/echarts'
import styles from './index.module.scss';

function initChart(canvas, width, height) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height
  })
  canvas.setChart(chart)
  const model = {
    yCates: ['Saturday', 'Friday', 'Thursday',
      'Wednesday', 'Tuesday', 'Monday',
      'Sunday'],
    xCates: ['1', '2', '3', '4', '5'],
    data: [
      // [yCateIndex, xCateIndex, value]
      [0, 0, 5], [0, 1, 7], [0, 2, 3], [0, 3, 5], [0, 4, 2],
      [1, 0, 1], [1, 1, 2], [1, 2, 4], [1, 3, 8], [1, 4, 2],
      [2, 0, 2], [2, 1, 3], [2, 2, 8], [2, 3, 6], [2, 4, 7],
      [3, 0, 3], [3, 1, 7], [3, 2, 5], [3, 3, 1], [3, 4, 6],
      [4, 0, 3], [4, 1, 2], [4, 2, 7], [4, 3, 8], [4, 4, 9],
      [5, 0, 2], [5, 1, 2], [5, 2, 3], [5, 3, 4], [5, 4, 7],
      [6, 0, 6], [6, 1, 5], [6, 2, 3], [6, 3, 1], [6, 4, 2]
    ]
  }

  const data = model.data.map(function (item) {
    return [item[1], item[0], item[2] || '-']
  })

  const option = {
    tooltip: {
      position: 'top'
    },
    animation: false,
    grid: {
      bottom: 60,
      top: 10,
      left: 80
    },
    xAxis: {
      type: 'category',
      data: model.xCates
    },
    yAxis: {
      type: 'category',
      data: model.yCates
    },
    visualMap: {
      min: 1,
      max: 10,
      show: false,
      calculable: true,
      orient: 'horizontal',
      left: 'center',
      bottom: 10,
      inRange: {
        color: ['#37A2DA', '#32C5E9', '#67E0E3', '#91F2DE', '#FFDB5C', '#FF9F7F'],
      }
    },
    series: [{
      name: 'Punch Card',
      type: 'heatmap',
      data: data,
      label: {
        normal: {
          show: true
        }
      },
      itemStyle: {
        emphasis: {
          shadowBlur: 10,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }]
  }

  chart.setOption(option)
  return chart
}

export default class Echarts extends React.Component {
constructor(props){
	super(props)
}
  config = {
    navigationBarTitleText: 'echarts-for-weixin 示例项目',
    navigationBarTextStyle: 'black',
    // navigationBarTitleText: 'WxParse 使用示例',
    backgroundColor: '#eeeeee',
    backgroundTextStyle: 'light',
    usingComponents: {
      'ec-canvas': '../../components/ec-canvas/ec-canvas' // 书写第三方组件的相对路径
    }
  }

  state = {
    ec: {
      onInit: initChart
    }
  }

  render () {
    return (
      <View className={styles.echarts}>
        <ec-canvas id='mychart-dom-area' canvas-id='mychart-area' ec={this.state.ec}></ec-canvas>
      </View>
    )
  }
}

@jinqh
Copy link

jinqh commented Dec 22, 2020

我和楼上遇到一样的问题,请问怎么处理

@jinqh
Copy link

jinqh commented Dec 22, 2020

遇到同样的问题,按照官方文档引入echarts-for-weixin,提示 WXMLRT_$gwx:./base.wxml:template:425:16: Template tmpl_0_ec-canvas not found.
参考链接:https://github.com/NervJS/taro-sample-weapp/blob/master/src/pages/echarts/echarts.js
"@tarojs/cli": "3.0.9"
demo

//  page/echarts/echarts.tsx
import React from 'react';
import { View } from '@tarojs/components'
import * as echarts from '../../components/ec-canvas/echarts'
import styles from './index.module.scss';

function initChart(canvas, width, height) {
  const chart = echarts.init(canvas, null, {
    width: width,
    height: height
  })
  canvas.setChart(chart)
  const model = {
    yCates: ['Saturday', 'Friday', 'Thursday',
      'Wednesday', 'Tuesday', 'Monday',
      'Sunday'],
    xCates: ['1', '2', '3', '4', '5'],
    data: [
      // [yCateIndex, xCateIndex, value]
      [0, 0, 5], [0, 1, 7], [0, 2, 3], [0, 3, 5], [0, 4, 2],
      [1, 0, 1], [1, 1, 2], [1, 2, 4], [1, 3, 8], [1, 4, 2],
      [2, 0, 2], [2, 1, 3], [2, 2, 8], [2, 3, 6], [2, 4, 7],
      [3, 0, 3], [3, 1, 7], [3, 2, 5], [3, 3, 1], [3, 4, 6],
      [4, 0, 3], [4, 1, 2], [4, 2, 7], [4, 3, 8], [4, 4, 9],
      [5, 0, 2], [5, 1, 2], [5, 2, 3], [5, 3, 4], [5, 4, 7],
      [6, 0, 6], [6, 1, 5], [6, 2, 3], [6, 3, 1], [6, 4, 2]
    ]
  }

  const data = model.data.map(function (item) {
    return [item[1], item[0], item[2] || '-']
  })

  const option = {
    tooltip: {
      position: 'top'
    },
    animation: false,
    grid: {
      bottom: 60,
      top: 10,
      left: 80
    },
    xAxis: {
      type: 'category',
      data: model.xCates
    },
    yAxis: {
      type: 'category',
      data: model.yCates
    },
    visualMap: {
      min: 1,
      max: 10,
      show: false,
      calculable: true,
      orient: 'horizontal',
      left: 'center',
      bottom: 10,
      inRange: {
        color: ['#37A2DA', '#32C5E9', '#67E0E3', '#91F2DE', '#FFDB5C', '#FF9F7F'],
      }
    },
    series: [{
      name: 'Punch Card',
      type: 'heatmap',
      data: data,
      label: {
        normal: {
          show: true
        }
      },
      itemStyle: {
        emphasis: {
          shadowBlur: 10,
          shadowColor: 'rgba(0, 0, 0, 0.5)'
        }
      }
    }]
  }

  chart.setOption(option)
  return chart
}

export default class Echarts extends React.Component {
constructor(props){
	super(props)
}
  config = {
    navigationBarTitleText: 'echarts-for-weixin 示例项目',
    navigationBarTextStyle: 'black',
    // navigationBarTitleText: 'WxParse 使用示例',
    backgroundColor: '#eeeeee',
    backgroundTextStyle: 'light',
    usingComponents: {
      'ec-canvas': '../../components/ec-canvas/ec-canvas' // 书写第三方组件的相对路径
    }
  }

  state = {
    ec: {
      onInit: initChart
    }
  }

  render () {
    return (
      <View className={styles.echarts}>
        <ec-canvas id='mychart-dom-area' canvas-id='mychart-area' ec={this.state.ec}></ec-canvas>
      </View>
    )
  }
}

我也遇到了,你解决了吗

@drunkWindy
Copy link
Author

drunkWindy commented Dec 22, 2020 via email

@Chen-jj
Copy link
Contributor

Chen-jj commented Mar 10, 2021

遇到同样的问题,按照官方文档引入echarts-for-weixin,提示 WXMLRT_$gwx:./base.wxml:template:425:16: Template tmpl_0_ec-canvas not found.
参考链接:https://github.com/NervJS/taro-sample-weapp/blob/master/src/pages/echarts/echarts.js
"@tarojs/cli": "3.0.9"

Vue2 应该参考 vue 分支:https://github.com/NervJS/taro-sample-weapp/tree/vue

@Chen-jj
Copy link
Contributor

Chen-jj commented Mar 10, 2021

相关平台

京东小程序

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

复现步骤

1、组件引入
config = {
usingComponents: {
parser: '@/utils/Parser/index' // 引入插件包
}
}
2、render () {
return (

)
}

期望结果

渲染富文本

实际结果

VM1098:1 ./base.wxml
Template tmpl_5_parser not found.
2115 |
2116 |

2117 |
| ^
2118 |
2119 |
2120 |

环境信息

Taro CLI 3.0.8 environment info:
    System:
      OS: Windows 10
    Binaries:
      Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.4 - C:\Users\PC\AppData\Roaming\npm\yarn.CMD
      npm: 6.14.6 - C:\Program Files\nodejs\npm.CMD

usingComponents 的 alias 当时没有支持,最新版本应该没有问题了。

@Chen-jj Chen-jj closed this as completed Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-jd Target - 编译到京东小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

5 participants