0👍
import foo from 'bar';
and var foo = require('bar');
does the same thing, making foo
available as a variable in the current file. In the test example, MyComponent
is the imported vue component instance, which can also be achieved with MyComponent = Vue.component(...);
in the current file. So if your test is in the same file, just use the MyComponent
variable, if not, you’ll need to export MyComponent
first with module.exports = MyComponent
or export default MyComponent
. These exports assume MyComponent
is the only thing you want to export, if you want to export multiple variables, checkout the docs: http://wiki.commonjs.org/wiki/Modules/1.1 https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/export
Source:stackexchange.com