Uncaught TypeError: Cannot read property 'setAttribute' of undefined at Object.onLoad
知道是什么导致了这个错误吗?
我的列表包括:
1 2 3 4 5 6 7 8 | <link rel="stylesheet" href="../../node_modules/semantic-ui/dist/semantic.min.css"> <link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="../../node_modules/fullcalendar/dist/fullcalendar.min.css"> <script src="../../node_modules/semantic-ui/dist/semantic.min.js"> <script src="../../node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"> <script src="../../node_modules/moment/min/moment.min.js"> <script src="../../node_modules/fullcalendar/dist/fullcalendar.min.js"> |
HTML元素:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <i class="calendar icon"> <span class="text">Choose a Month</span> January February March April May June July August September October November December |
脚本:
1 | $('#monthDrop').dropdown(); |
它在加载时呈现良好和所有内容,并且没有错误,仅当我尝试单击它时:
我们使用以下HTML遇到了相同的错误:
1 2 3 4 5 | <select class="btn btn-secondary dropdown-toggle" data-toggle="dropdown" role="button" v-model="selected" aria-haspopup="true" aria-expanded="false"> <option disabled value="">Please select one</option> <option class="dropdown-item" value="type1">Carrier</option> <option class="dropdown-item" value="type2">Shipper</option> </select> |
我们试图从
CSS框架
首先,你必须选择是使用
假设您选择Bootstrap 4,因为它更简单,更容易学习,尤其是初学者(当然,您可以选择语义UI、基础或任何其他如果您愿意),您应该在代码中有这两个脚本:jQuery和Popper.js。
从引导文件:
Many of our components require the use of JavaScript to function. Specifically, they require jQuery, Popper.js, and our own JavaScript plugins.
同样,你可以在文档中找到:
Dropdowns are built on a third party library, Popper.js, which provides dynamic positioning and viewport detection. Be sure to include popper.min.js before Bootstrap’s JavaScript or use bootstrap.bundle.min.js / bootstrap.bundle.js which contains Popper.js. Popper.js isn’t used to position dropdowns in navbars though as dynamic positioning isn’t required.
当您决定要使用哪个CSS框架时,您将能够以适当的方式设置您的
正如我看到的,您可以通过
npm is a package manager for Node.js packages
我猜你想做的是在你的本地文件夹里,比如
您可以在这里找到许多关于节点和JavaScript的有用注释。
将semanticui链接保持在引导程序链接的下方
1 2 3 4 | <link rel="stylesheet" href="../../node_modules/font-awesome/css/font-awesome.min.css"> <link rel="stylesheet" href="../../node_modules/bootstrap/dist/css/bootstrap.min.css"> <link rel="stylesheet" href="../../node_modules/semantic-ui/dist/semantic.min.css"> <link rel="stylesheet" href="../../node_modules/fullcalendar/dist/fullcalendar.min.css"> |