Javascript 以视图方式导入fullPage.js
我正试图从我在Marionette.js网站上找到的Browserify和Grunt骨架开始,在Marionette中编写一个简单的应用程序结构: 我以前没有使用过木偶和Browserify,而且我还不太习惯ES2015语法 如何导入插件,即在视图中使用插件 这是我的view.js:Javascript 以视图方式导入fullPage.js,javascript,browserify,marionette,fullpage.js,Javascript,Browserify,Marionette,Fullpage.js,我正试图从我在Marionette.js网站上找到的Browserify和Grunt骨架开始,在Marionette中编写一个简单的应用程序结构: 我以前没有使用过木偶和Browserify,而且我还不太习惯ES2015语法 如何导入插件,即在视图中使用插件 这是我的view.js: import {Marionette} from '../../../vendor/vendor'; import template from '../../templates/homepage.jst'; exp
import {Marionette} from '../../../vendor/vendor';
import template from '../../templates/homepage.jst';
export default Marionette.View.extend({
el: '#app',
template: template
});
我已经用npm加载了它,并且已经将它捆绑在“供应商”中了
我实际上是在寻找与
<script src="node_modules/fullpage.js/dist/jquery.fullpage.min.js></script>
如果其他人感兴趣
我是这样解决的:
1) 我是通过npm安装的。这使得CommonJS不兼容的文件可以浏览(就像fullPage.js一样)
2) 添加到package.json:
由于某些原因,它不会占用我到node_modules/文件夹的整个路径,因此我必须将.js文件复制到项目的根目录下(package.json和Gruntfile.js旁边)如果有人能找出它为什么不适用于node_模块文件夹,那就太好了
3) 将此添加到Gruntfile.js:
在这里,我将fullpage.js添加到我在构建项目中使用的app.js中
4) 最后,我在视图的渲染中添加了以下内容:
import {Marionette} from '../../../vendor/vendor';
import template from '../../templates/homepage.jst';
export default Marionette.View.extend({
el: '#app',
template: template,
onRender: function() {
$('.fullpage').fullpage();
}
});
就这些我遇到了同样的问题:fullpage.js文件的位置。当我将fullpage.js文件夹重命名为fullpagejs作为暗箭伤人的手段,然后将其重新命名时,问题就解决了。魔术
grunt.initConfig({
browserify: {
dist: {
options: {
transform: [
['babelify', {
'presets': ['es2015']
}],
['jstify']
]
},
files: {
'./public/app.js': [
'./app/initialize.js',
'./jquery.fullpage.min.js'
]
}
}
}
import {Marionette} from '../../../vendor/vendor';
import template from '../../templates/homepage.jst';
export default Marionette.View.extend({
el: '#app',
template: template,
onRender: function() {
$('.fullpage').fullpage();
}
});