Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SheenyMeg opened this issue Nov 9, 2020 · 3 comments
Open

Comments

@SheenyMeg
Copy link

SheenyMeg commented Nov 9, 2020

//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配置项,重新编译后页面才可以显示图标,无报错。

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

@SheenyMeg SheenyMeg reopened this Nov 9, 2020
@fwh1990
Copy link
Member

fwh1990 commented Nov 9, 2020

taro info 贴一下吧,谢谢

@Mar-er
Copy link

Mar-er commented Jan 9, 2021

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
Copy link
Author

SheenyMeg commented Mar 10, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants