gpt4 book ai didi

material-design - 从 angularjs 初始化 materializecss 下拉菜单时出错

转载 作者:行者123 更新时间:2023-12-01 12:40:37 24 4
gpt4 key购买 nike

我正在从 angularjs 模板动态加载 materializecss 下拉列表。所以在加载主页时在开始时初始化它是行不通的。我添加了以下代码来初始化其他元素以及最后一行的下拉列表

//Inside angularjs controller
//Main Left Sidebar Menu
$('.sidebar-collapse').sideNav();

// FULL SCREEN MENU (Layout 02)
$('.menu-sidebar-collapse').sideNav();

// HORIZONTAL MENU (Layout 03)
$('.dropdown-menu').dropdown();

$('.button-collapse').sideNav();

$('.collapsible').collapsible();

$('.dropdown-button').dropdown();

除下拉列表外,所有其他元素都已初始化。由于最后一行,我收到以下错误,如果我删除该行,除下拉菜单外一切正常。我是 Angular JS 和前端开发的新手。我已经在网上搜索过,仍然找不到任何答案。如果你能帮助我,我将不胜感激。

TypeError: Cannot read property 'childNodes' of undefined
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:36)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at compositeLinkFn (http://localhost/TempProject2/js/angular/angular.js:7641:13)
at nodeLinkFn (http://localhost/TempProject2/js/angular/angular.js:8241:24) <div ui-view="" class="ng-scope">

最佳答案

我通过将下拉内容包含在包含下拉列表数据激活属性的 anchor 标记中来使其工作。看看下面的代码:

  <!-- Dropdown Trigger -->
<li><a class="dropdown-button" href="#!" data-activates="dropdown1" id="test">Dropdown<i class="material-icons right">arrow_drop_down</i>
<!-- Dropdown Structure -->
<ul id="dropdown1" class="dropdown-content">
<li><a href="#!">one</a></li>
<li><a href="#!">two</a></li>
<li class="divider"></li>
<li><a href="#!">three</a></li>
</ul>
</a>
</li>

关于material-design - 从 angularjs 初始化 materializecss 下拉菜单时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32340725/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com