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

微信小程序插件引用图片路径编译报错 #4231

Closed
IDrinkMoreWater opened this issue Aug 20, 2019 · 6 comments
Closed

微信小程序插件引用图片路径编译报错 #4231

IDrinkMoreWater opened this issue Aug 20, 2019 · 6 comments
Assignees

Comments

@IDrinkMoreWater
Copy link

IDrinkMoreWater commented Aug 20, 2019

问题描述
微信小程序插件引用图片路径编译报错

复现步骤
[复现问题的步骤]

  1. taro init 初始化微信小程序插件项目
  2. 页面插件src/plugin/pages/list目录下新增images文件夹
  3. 修改 list路径下list.tsx页面代码,添加引用images下的图片代码,如navigationIcon ,searchIcon
import Taro, { Component } from '@tarojs/taro'
import { View, Image } from '@tarojs/components';
import ListItem from '../../components/listItem/listItem'
import './list.less'
import navigationIcon from './images/navigation.png';
import searchIcon from './images/icon_search.png';
export default class Index extends Component {
  state = {
    list: [{
      name: 'A',
      value: '1'
    }, {
      name: 'B',
      value: '2'
    }, {
      name: 'C',
      value: '3'
    }]
  }

  render () {
    return (
      <View>
	    <Image src={navigationIcon}/>
	   <Image src={searchIcon}/>
        {this.state.list.map(item => {
          return <ListItem name={item.name} value={item.value} key={item.name} />
        })}
      </View>
    )
  }
}

期望行为
页面正常编译正常引用图片

报错信息
image

完整错误信息:
(node:9132) UnhandledPromiseRejectionWarning: Error: EEXIST: file already exists, mkdir 'D:\Document
s\Desktop\plugin\miniprogram\plugin\pages\list\images'
(node:9132) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated eit
her by throwing inside of an async function without a catch block, or by rejecting a promise which w
as not handled with .catch(). (rejection id: 1)
(node:9132) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future
, promise rejections that are not handled will terminate the Node.js process with a non-zero exit co
de.

系统信息
Taro CLI 1.3.11 environment info:
System:
OS: Windows 7
Binaries:
Node: 8.11.2 - C:\Program Files (x86)\nodejs\node.EXE
npm: 5.6.0 - C:\Program Files (x86)\nodejs\npm.CMD

  • 报错平台 [ weapp-plugin]

其他重要补充信息:
以上示例代码,发现只import引用1张图片时不会报错,2张或2张以上时才会发现报错

@taro-bot
Copy link

taro-bot bot commented Aug 20, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@IDrinkMoreWater
Copy link
Author

问题没解决,还有其他问题,dev:weapp 编译现在是首次编译不会报错,但是改动文件后自动编译的还会报错
微信图片_20190829170115
build:weapp下编译不会报错,运行后会报错
image

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 3, 2019

@IDrinkMoreWater 复现不了,修改后并没有报错

image

image

@IDrinkMoreWater
Copy link
Author

IDrinkMoreWater commented Sep 15, 2019

@Chen-jj 你是用jsx编译的所以正常,init项目的时候选择typescript就能重现了,应该是这个原因,我用脚手架从新初始化了一个新的空项目,安装上面的复现步骤是可以重现的

@Chen-jj
Copy link
Contributor

Chen-jj commented Sep 17, 2019

@IDrinkMoreWater 是不是用错命令,应该是 taro build --plugin weapp --watch

@IDrinkMoreWater
Copy link
Author

@Chen-jj 嘉健兄能加微信聊么,确实没用错命令啊,我用taro build --plugin weapp --watch不报错, taro build --plugin weapp才报错哦

Chen-jj added a commit that referenced this issue Sep 17, 2019
编译时替换静态资源的正则改成非贪婪模式
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

2 participants