在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Taro微信小程序可以用wxParse来达到html转换wxml的效果:https://github.com/NervJS/taro-components-test/blob/master/src/pages/wxParse/wxParse.js import Taro, { Component } from '@tarojs/taro' import { View, Text, Image, Button } from '@tarojs/components' import WxParse from '../../wxParse/wxParse' import "../../wxParse/wxParse.wxss"; class Home extends Component { constructor() { super(...arguments); this.state = ({ }) } config = { navigationBarTitleText: '首页' } componentWillMount() { } componentDidMount() { const article = '<div style="color: red">我是HTML代码</div><h2>标题2</h2><img src="http://192.168.122.142:80/public/1904/26/public-1904-26-c15d9fb7-0ad5-40a9-b845-6d085d6c0f30.jpg">' WxParse.wxParse('article', 'html', article, this.$scope, 5) } render() { return ( <View className="home"> <import src='../../wxParse/wxParse.wxml' /> <template is='wxParse' data='{{wxParseData:article.nodes}}'/> </View> ) } } export default Home
|
请发表评论