2
我正在使用Angular Material,當我在應用程序中放入一個MD菜單時,顯示一個錯誤。這是錯誤:Angular Material md-menu無法讀取屬性'setAttribute'爲空
TypeError: Cannot read property 'setAttribute' of null
代碼:
<md-menu>
<md-button ng-click="$mdOpenMenu($event)" class="md-icon-button" aria-label="Open sample menu">
<md-icon md-svg-icon="call:phone"></md-icon>
</md-button>
<md-menu-content>
<md-menu-item>
<md-button ng-click="doSomething()">Do Something</md-button>
</md-menu-item>
</md-menu-content>
</md-menu>
我使用涼亭和錯誤開始的時候我上傳角材料的版本,從0.11.0到1.0.1出現。這是我bower.json:
{
"name": "Angular-Base",
"dependencies": {
"angucomplete-alt": "~1.1.0",
"angular": "~1.4.0",
"angular-animate": "~1.4.3",
"angular-aria": "~1.4.3",
"angular-chart.js": "~0.7.2",
"angular-drag-and-drop-lists": "~1.2.0",
"angular-emoji": "~0.1.0",
"angular-emoji-filter-hd": "~0.0.6",
"angular-material": "1.0.1",
"angular-md5": "~0.1.8",
"angular-messages": "~1.4.7",
"angular-sanitize": "~1.4.3",
"angular-ui-router": "0.2.15",
"hint.css": "~1.3.5",
"jquery-legacy": "jquery#1.11.3",
"moment": "~2.10.6",
"ng-file-upload": "~6.2.1",
"ngWYSIWYG": "*",
"angular-material-data-table": "0.9.7",
"perfect-scrollbar": "~0.6.8"
},
"devDependencies": {
"angular-translate": "~2.7.2",
"angular-translate-loader-static-files": "~2.7.2"
},
"resolutions": {
"angular": "1.4.7",
"angular-sanitize": "~1.4.3"
}
而且我閱讀和測試this question沒有成功...
提的是一切是正確的,並在菜單中工作(點擊動作也很好)但是,每當我把一個MD菜單時,出現在控制檯中的錯誤...所以我想修復...
謝謝!
你真的需要$ mdOpenMenu嗎?試着重複1.0.1版本的md-menu例子。 https://material.angularjs.org/latest/demo/menu –
http://codepen.io/anon/pen/KVqBeb –
您應該首先確保所有的角度庫都具有相同的版本。 – kuhnroyal