wepy-plugin-htmltag

1.0.0 • Public • Published

wepy-plugin-htmltag

wepy 插件,转化html标签为view, text, image标签, 并修改wxss内标签选择器

示例

test.wpy

<template>
  <div class="container">
    <ul>
      <li class="item"><span>Item 1</span></li>
    </ul>
  </div>
</template>

<style lang="scss">
  div.container ul li:first-of-type{
    span{
      float: left;
    }
    img{
      float: right;
    }
  }
</style>

转化后test.wxml

<view class="_div container">
  <view class="_ul">
    <view class="_li item"><text class="_span">Item 1</text><image class="_img" src=""></image></view>
  </view>
</view>

test.wxss

._div.container ._ul ._li:first-of-type ._span {
  float: left;
}

._div.container ._ul ._li:first-of-type ._img {
  float: right;
}

安装

  $ npm i -D wepy-plugin-tag

使用

wepy.config.js

module.exports.plugins = {
  htmltag: {
    filter: /\.(wxml|wxss)$/,
    config: {
      /* block: [...], */
      /* inline: [...], */
    }
  }
}

配置

  • filter 监听的文件后缀
    默认: /\.(wxml|wxss)$/

  • config 具体配置

    • config.block 块元素数组,转化为view 标签
      默认: ['div'....]

    • config.inline 内联元素数组,转化为text 标签
      默认: ['span'....]

*注意:img固定转化为image, <br>固定转化为<text>\n</text>, 配置内只影响是否转换

Readme

Keywords

Package Sidebar

Install

npm i wepy-plugin-htmltag

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

10.1 kB

Total Files

6

Last publish

Collaborators

  • ryzon