[英]EmberJS how to include another Ember.Object file
Situation 情况
I'm using EmberCLI for my Emberjs project. 我正在将EmberCLI用于我的Emberjs项目。 I created a directory called "custom_objects" with a file inside of it called 'person.js'
我创建了一个名为“custom_objects”目录与文件里面它叫“person.js”
Emberjs Directory Emberjs目录
LearningService (my app name)
+ app
+ components
+ controllers
+ custom_objects
-person.js*
+ helpers
+ models
+ routes
+ services
+ styles
+ templates
I am now working inside the components folder on a file called 'person-list.js' I want to make the person.js file available in person-list.js so I typed out the following: 我现在在名为“ person-list.js”的文件中的components文件夹中工作,我想在person-list.js中使 person.js文件可用,因此我输入了以下内容:
custom_objects/person.js custom_objects / person.js
import Ember from 'ember';
export default Ember.Object.extend({
name: 'person'
});
components / person-list.js 组件/ person-list.js
import Ember from 'ember';
import Person from '../custom_objects/person.js';
export default Ember.Component.extend({
});
This is the error I get from the console 这是我从控制台收到的错误
Uncaught Error: Could not find module `learning-services/custom_objects/person.js` imported from `learning-services/components/person-list`
From the documentation I have read your supposed to use relative path and just include it as shown above. 从文档中,我已经阅读了您应该使用的相对路径,并且仅包含了它,如上所示。
• I have tried restarting Ember server •我尝试重新启动Ember服务器
What am I missing? 我想念什么?
不需要.js
扩展名:
import Person from '../custom_objects/person';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.