Uni Helper

旨在增强 uni-app 系列产品的开发体验

上查看 vite-plugin-uni-platform-modifier 10

vite-plugin-uni-platform-modifier

为属性、指令提供平台修饰符并按需编译

安装

pnpm i -D @uni-helper/vite-plugin-uni-platform-modifier

使用

配置

// vite.config.ts
import { defineConfig } from 'vite'
import Uni from '@dcloudio/vite-plugin-uni'
import UniPlatformModifier from '@uni-helper/vite-plugin-uni-platform-modifier'

export default defineConfig({
  plugins: [Uni(), UniPlatformModifier()],
})

编写代码

<button
  v-text="'hello'"
  v-text.h5.mp-weixin="'h5&mp-weixin'"
  class.h5="h5-class"
  class="default-class"
  @click.h5="handleH5Click"
  @click="handleDefaultClick"
/>
编译到H5
<button
  v-text="'h5&mp-weixin'"
  class="h5-class"
  @click="handleH5Click"
/>
编译到微信小程序
<button
  v-text="'h5&mp-weixin'"
  class="default-class"
  @click="handleDefaultClick"
/>
编译到其他平台
<button
  v-text="'hello'"
  class="default-class"
  @click="handleDefaultClick"
/>

支持的修饰符

['app', 'app-plus', 'h5', 'mp-360', 'mp-alipay', 'mp-baidu', 'mp-jd', 'mp-kuaishou', 'mp-lark', 'mp-qq', 'mp-toutiao', 'mp-weixin', 'quickapp-webview', 'quickapp-webview-huawei', 'quickapp-webview-union']