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

在 tsx 怎么导入 .json 文件,执行后报错 #5003

Closed
supermavericks opened this issue Dec 4, 2019 · 5 comments
Closed

在 tsx 怎么导入 .json 文件,执行后报错 #5003

supermavericks opened this issue Dec 4, 2019 · 5 comments
Assignees

Comments

@supermavericks
Copy link

问题描述

在 .tsx文件中导入 .json 文件。编译执行后报错:
Uncaught Error: module "名字.json" is not defined

复现步骤

导入方法如下

import * as ViewMapping from '../view.mapping.json'

使用 {ViewMapping.name}

报错信息

Uncaught Error: module "view.mapping.json" is not defined

系统信息

Taro CLI 1.3.25 environment info:
System:
OS: macOS 10.14.4
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.13.0 - ~/.nvm/versions/node/v8.13.0/bin/node
Yarn: 1.16.0 - ~/.yarn/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.13.0/bin/npm
npmPackages:
@tarojs/components: 1.3.25 => 1.3.25
@tarojs/plugin-babel: 1.3.25 => 1.3.25
@tarojs/plugin-csso: 1.3.25 => 1.3.25
@tarojs/plugin-sass: 1.3.25 => 1.3.25
@tarojs/plugin-uglifyjs: 1.3.25 => 1.3.25
@tarojs/router: 1.3.25 => 1.3.25
@tarojs/taro: 1.3.25 => 1.3.25
@tarojs/taro-alipay: 1.3.25 => 1.3.25
@tarojs/taro-h5: 1.3.25 => 1.3.25
@tarojs/taro-qq: 1.3.25 => 1.3.25
@tarojs/taro-quickapp: 1.3.25 => 1.3.25
@tarojs/taro-swan: 1.3.25 => 1.3.25
@tarojs/taro-tt: 1.3.25 => 1.3.25
@tarojs/taro-weapp: 1.3.25 => 1.3.25
@tarojs/webpack-runner: 1.3.25 => 1.3.25
eslint-config-taro: 1.3.25 => 1.3.25
eslint-plugin-taro: 1.3.25 => 1.3.25
nerv-devtools: ^1.5.0 => 1.5.5
nervjs: ^1.5.0 => 1.5.5
stylelint-config-taro-rn: 1.3.25 => 1.3.25
stylelint-taro-rn: 1.3.25 => 1.3.25
npmGlobalPackages:
typescript: 3.6.4

补充信息

请问如何正确导入 .json文件?谢谢

@taro-bot
Copy link

taro-bot bot commented Dec 4, 2019

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Dec 4, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@shenghanqin
Copy link
Collaborator

有问题先去官网看文档哟。🙂

引用 JSON 文件

@taro-bot
Copy link

taro-bot bot commented Dec 4, 2019

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@supermavericks
Copy link
Author

@shenghanqin 👌 谢谢

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