亚洲精品久久久中文字幕-亚洲精品久久片久久-亚洲精品久久青草-亚洲精品久久婷婷爱久久婷婷-亚洲精品久久午夜香蕉

您的位置:首頁技術(shù)文章
文章詳情頁

angular.js - 已實(shí)現(xiàn)的angularjs項(xiàng)目用requirejs進(jìn)行模塊化時(shí)遇到問題

瀏覽:67日期:2024-10-06 16:17:14

問題描述

其實(shí)就是對todoMVC項(xiàng)目用requirejs進(jìn)行模塊化。原本的angularjs是分別在controller、directive、service中分別定義了一個(gè)模塊來代表這三者。下面是directive:todoFocus.js

(function () { ’use strict’ angular.module(’todoFocus’,[]).directive(’todoFocus’,function ($timeout){return function (scope,element,attrs){ scope.$watch(attrs.todoFocus,function (newVal){if(newVal){ $timeout(function(){element[0].focus(); },0,false);} })} })})()

上面就是一個(gè)directive。之后在app.js中

(function () { ’use strict’; angular.module(’todomvc’, [’todoCtrl’, ’todoFocus’, ’todoStorage’]);})();

我用requirejs模塊化之后directive變成了這樣:

(function () { ’use strict’ define([’angular’],function (angular) {angular.module(’todoFocus’,[]).directive(’todoFocus’,function ($timeout){return function (scope,element,attrs){ scope.$watch(attrs.todoFocus,function (newVal){if(newVal){ $timeout(function(){element[0].focus(); },0,false);} })} })return ’todoFocus’; })})()

然后app.js變成了這樣:

(function () { ’use strict’; require([’angular’],function (angular) {require([ ’controllers/todoCtrl’, ’directives/todoFocus’, ’services/todoStorage’ ],function (todoCtrl,todoFocus,todoStorage) {angular.module(’todomvc’,[todoCtrl,todoFocus,todoStorage]);angular.bootstrap(document, [’todomvc’]); }) })})();

之后打開網(wǎng)頁發(fā)現(xiàn)所有的js文件都加載出來了,但是并不能實(shí)現(xiàn)效果。。angular.js - 已實(shí)現(xiàn)的angularjs項(xiàng)目用requirejs進(jìn)行模塊化時(shí)遇到問題

angular.js - 已實(shí)現(xiàn)的angularjs項(xiàng)目用requirejs進(jìn)行模塊化時(shí)遇到問題

是不是app.js不能這么寫。沒怎么用過requireJS/(ㄒoㄒ)/~~

貼一下我的文件路徑angular.js - 已實(shí)現(xiàn)的angularjs項(xiàng)目用requirejs進(jìn)行模塊化時(shí)遇到問題

下面是我的main.js

(function (win) { ’use strict’; require.config({paths: { angular: ’../node_modules/angular/angular’},shim: { //專門用來配置不兼容的模塊 angular: { exports: ’angular’ //輸出變量名,表示這個(gè)模塊外部調(diào)用時(shí)的名稱 }},deps: [’app’] //deps數(shù)組,表示該模塊依賴app模塊,所以要先加載app模塊});})(window)

感覺我的路徑?jīng)]啥問題呀/(ㄒoㄒ)/~~

問題解答

回答1:

模塊依賴注入錯(cuò)誤了,檢查下引用路徑

相關(guān)文章:
主站蜘蛛池模板: 国产美女极品免费视频 | 高清视频欧美性生活 | 亚洲一二三区在线观看 | 亚洲欧美日韩三级 | 国产精品一区二区三区四区五区 | 丝袜美腿亚洲综合 | 亚洲免费国产 | 日本国产在线视频 | 亚洲啪| 成人精品视频网站 | 91社区在线观看 | 91麻豆国产极品在线观看洋子 | 国产91久久精品一区二区 | 久久精品国产999久久久 | 成人免费观看国产高清 | 久久国产成人福利播放 | 免费中文字幕视频 | 亚洲婷婷天堂在线综合 | 精品日产一区二区三区手机 | 成人黄色在线免费观看 | 午夜剧场福利社 | 免费国产人做人视频在线观看 | 18禁片一级毛片视频播放免费看 | 日韩黄色网页 | 国产特级毛片 | 亚洲欧美日韩高清专区一区 | 爆操御姐| 亚洲日韩欧美综合 | 国内精品久久久久久西瓜色吧 | 亚洲成人在线网站 | 青青热久免费精品视频在线观看 | 国产亚洲美女精品久久久2020 | 国产在线观看福利一区二区 | 2021年韩国r级理论片在线观看 | 久久精品视频在线观看 | 一级毛片黄色片 | 亚洲国产精品婷婷久久 | 国产精品久久久久久爽爽爽 | 看全色黄大色大片免费久黄久 | 成人做爰全过程免费看网站 | 婷婷综合色伊人阁 |