taro-iconfont-cli icon indicating copy to clipboard operation
taro-iconfont-cli copied to clipboard

关于在app.config.ts/js里配置usingComponents的解决方案

Open tom-hanks opened this issue 2 years ago • 1 comments

大家直接在app.config.ts或者app.config.js里写如下代码

export default defineAppConfig({
  pages: [
    'pages/chat/chat',
    'pages/index/index',
  ],
  window: {
    backgroundTextStyle: 'light',
    navigationBarBackgroundColor: '#fff',
    navigationBarTitleText: 'WeChat',
    navigationBarTextStyle: 'black'
  },
  usingComponents: Object.assign({
    iconfont: `components/iconfont/${process.env.TARO_ENV}/${process.env.TARO_ENV}`,
  })
})

usingComponents和window同级,引入的话不要引入helper文件,会报错的,,直接在这里配置 iconfont: components/iconfont/${process.env.TARO_ENV}/${process.env.TARO_ENV}, 完美解决

tom-hanks avatar Mar 27 '23 06:03 tom-hanks

taro4.1.1 版本

app.config.ts 中,下面这样写也可以,但不知道与 Object.assign 有什么区别。

usingComponents: { iconfont:components/iconfont/${process.env.TARO_ENV}/${process.env.TARO_ENV}, },

timerlau avatar Jun 06 '25 23:06 timerlau