zoukankan      html  css  js  c++  java
  • Taro -- 微信小程序wxParse达到html转换wxml

    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
  • 相关阅读:
    64_q2
    64_q1
    64_p10
    64_p9
    64_p8
    64_p7
    64_p6
    64_p5
    64_p4
    64_p3
  • 原文地址:https://www.cnblogs.com/juewuzhe/p/11136615.html
Copyright © 2011-2022 走看看