要求功能没有定义?

时间:2017-06-23 09:59:59

标签: javascript require

我正在尝试将材料 - 照片库实现到我的项目中。这是我的代码:

//config .state("patents.item", { url: "/:id", templateUrl: "templates/patents/list/patent-item.htm", controller: "patentItem", //<-- controller added here controllerAs: "item" }) //patenItem new controller .controller('patentItem', ['patentsService', function(patentsService) { var item = this; item.select = function(items) { vm.patentItem = patentsService.select(item); console.log(vm.patentItem) }; function init(){ item.select(); } init(); }]);

main.js

var MaterialPhotoGallery = require('material-photo-gallery'); var elem = document.querySelector('.m-p-g'); var gallery = new MaterialPhotoGallery(elem);

Package.json

但是,当我打开浏览器时,我得到{ "name": "web-site-project", "version": "1.0.0", "main": "main.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "keywords": [], "description": "", "devDependencies": { "material-photo-gallery": "^0.1.1" }, "dependencies": { "browserify": "^14.4.0" } }

我尝试使用main.js:1 Uncaught ReferenceError: require is not defined at main.js:1捆绑main.js文件,但仍然没有运气。有什么指示或建议吗?

0 个答案:

没有答案