iconfont-cli / taro-iconfont-cli

在Taro框架中使用iconfont图标,支持多端,支持多色彩,不依赖字体。
MIT License
344 stars 49 forks source link

[ appservice 生成错误] dist/components/iconfont/index.weapp.js: #41

Open SheenyMeg opened 3 years ago

SheenyMeg commented 3 years ago

//index.weapp.js

`/ eslint-disable /

import React from 'react'; import Taro from '@tarojs/taro';

const IconFont = (props) => { const { name, size, color } = props;

return ; };

IconFont.defaultProps = { size: 18, };

export default IconFont;`

微信开发工具报错如下: 错误一: app.js错误: Error: module "app.js" is not defined at require (VM43 WAService.js:2) at :3:7 at doWhenAllScriptLoaded (appservice?t=1604853668269:9863) at HTMLScriptElement.scriptLoaded (appservice?t=1604853668269:9883) at HTMLScriptElement.script.onload (appservice?t=1604853668269:9891)

错误二: [ appservice 生成错误] dist/components/iconfont/index.weapp.js: file: components/iconfont/index.weapp.js unknown: Unexpected token (9:9)

7 | const { name, size, color } = props; 8 |

9 | return ; | ^ 10 | }; 11 | 12 | IconFont.defaultProps = {

有遇到过这类问题吗?

后来在组件的config.json文件中添加: usingComponents: {"iconfont": "../../components/iconfont"}, 并去掉app.config.json文件中的:usingComponents: Object.assign(useGlobalIconFont())后,以上报错会消失,显示新的报错,如下: [ dist/pages/detail/detail.json 文件内容错误] dist/pages/detail/detail.json: ["usingComponents"]["IconFont"]: "../../components/iconfont/index.weapp" 未找到

接着删掉组件config.json中的usingComponents配置项,并恢复app.config.json文件中的usingComponents配置项,重新编译后页面才可以显示图标,无报错。

每次重启编译都会出现以上问题。

fwh1990 commented 3 years ago

taro info 贴一下吧,谢谢

Mar-er commented 3 years ago

image 开发工具报错 @fwh1990 � Taro v3.1.0-beta.4

Taro CLI 3.1.0-beta.4 environment info: System: OS: Windows 10 Binaries: Node: 12.20.0 - C:\software\program\Node\node.EXE Yarn: 1.22.10 - C:\software\program\Node\yarn.CMD npm: 6.14.8 - C:\software\program\Node\npm.CMD

SheenyMeg commented 3 years ago

taro info 贴一下吧,谢谢

无论是在npm run dev还是npm run build编译后,微信开发工具里总是出现index.weapp.js文件中的这段代码有报错:

  [ appservice 生成错误] dist/components/iconfont/index.weapp.js: file: components/iconfont/index.weapp.js
 unknown: Unexpected token (9:9)

   7 |   const { name, size, color, style } = props
   8 | 
>  9 |   return <iconfont name={name} size={parseFloat(Taro.pxTransform(size))} color={color} style={style} />
     |          ^
  10 | }
  11 | 
  12 | IconFont.defaultProps = {

Taro Info 如下: Taro CLI 3.1.2 environment info: System: OS: Windows 10 Binaries: Node: 12.20.2 - C:\Program Files\nodejs\node.EXE npm: 7.6.1 - C:\Program Files\nodejs\npm.CMD