Skip to content

Latest commit

 

History

History

replace-template-tag

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Vue 模板标签转换

替换 Vue 模板中的标签,比如把REPLACE_TAG_SCROLL_VIEWweb端替换成div,在小程序端替换为scroll-view

如何使用

vue.config.js 中添加如下设置:

const { LOADER_MAP } = 'plugin-light/lib/loader';

module.export = {
  chainWebpack(config) {
    config.module
      .rule('vue')
      .test(/\.vue$/)
      .use(LOADER_MAP.replaceTemplateTag)
      .loader(LOADER_MAP.replaceTemplateTag)
      .options({
        replaceTmpTagMap: {
          REPLACE_TAG_SCROLL_VIEW: {
            web: 'div',
            mp: 'scroll-view',
          },
        }
      })
      .end();
  }
}

参数

export type IReplaceTemplateTagOptions = {
  // 替换标签映射表
  replaceTmpTagMap?: {
    [k: string]: {
      mp: string;
      web: string;
    }
  }
};