javascript - 选项卡组件 - javascript 未定义错误
问题描述
您好,我不明白为什么我的标签组件不起作用。你看出什么不对了吗?
这是错误: Uncaught ReferenceError: openService is not defined
function openService(evt, serviceName) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("block-services");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("li-services");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(serviceName).style.display = "block";
evt.currentTarget.className += " active";
}
解决方案
推荐阅读
- python - 使用机器学习循环访问 Dask 中的变量
- torch - PyTorch:错误消息“火炬没有 [...] 成员”
- java - JavaFX 移动国际象棋人物
- c++ - 如何在 GCC 中获取线程模型?
- javascript - 我不明白为什么 cordova 链接和 Javascript 编码不起作用
- c# - C# DateTime Online 没有当前设备 DateTime
- scala - Akka Streams WebSocket 发送有关任意事件的信息
- android - 从 DB 到 ImageView 背景的字符串图像引用
- python - 如何使用按钮重新启动 Python GUI 程序?
- java - 编码和解码后字符串不同