在 ember js 中导入模块时出现异常
exception while importing module in ember js
我需要从 emberjs 应用程序的字符串中删除变音符号。
我为此找到了一个插件:fold-to-ascii
但我不知道如何在我的应用程序中使用它。
我通过 npm 添加了这个插件,它在我的应用程序的 node_modules 文件夹下可见
在文档中这个插件的用法是:
var foldToAscii = require("fold-to-ascii");
foldToAscii.fold("★Lorém ïpsum dölor.")
但我得到一个例外:
Uncaught Error: Could not find module fold-to-ascii
也尝试像@Kori John Roys 建议的那样导入它:
import foldToAscii from 'fold-to-ascii'
但它只给了我新的例外:
Error while processing route: transports.index
Could not find module fold-to-ascii imported from test-ember/pods/transport/model
我做错了什么?
假设您正在使用 ember-cli:
npm install --save-dev ember-browserify
然后你可以这样导入:
import foldToAscii from "npm:fold-to-ascii"
我需要从 emberjs 应用程序的字符串中删除变音符号。 我为此找到了一个插件:fold-to-ascii 但我不知道如何在我的应用程序中使用它。
我通过 npm 添加了这个插件,它在我的应用程序的 node_modules 文件夹下可见
在文档中这个插件的用法是:
var foldToAscii = require("fold-to-ascii");
foldToAscii.fold("★Lorém ïpsum dölor.")
但我得到一个例外:
Uncaught Error: Could not find module fold-to-ascii
也尝试像@Kori John Roys 建议的那样导入它:
import foldToAscii from 'fold-to-ascii'
但它只给了我新的例外:
Error while processing route: transports.index
Could not find module fold-to-ascii imported from test-ember/pods/transport/model
我做错了什么?
假设您正在使用 ember-cli:
npm install --save-dev ember-browserify
然后你可以这样导入:
import foldToAscii from "npm:fold-to-ascii"