我有这个错误,看起来我没有将变量导入到组件中。但这是我的style.scss
`
/* You can add global styles to this file, and also import other style files */
/**
* Foundation for Sites by ZURB
* Version 6.4.4-rc1
* foundation.zurb.com
* Licensed under MIT Open Source
*/
// Dependencies
@import '../node_modules/foundation-sites/scss/foundation';
@import '../node_modules/foundation-sites/_vendor/normalize-scss/sass/normalize';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/helpers/missing-dependencies';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/helpers/true';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/functions/contain';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/functions/purge';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/functions/remove';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/functions/replace';
@import '../node_modules/foundation-sites/_vendor/sassy-lists/stylesheets/functions/to-list';
// Settings
// import your own `settings` here or
// import and modify the default settings through
@import '../node_modules/foundation-sites/scss/settings/settings';
// Sass utilities …Run Code Online (Sandbox Code Playgroud) 我正在尝试让 div 的子元素切换类“活动”
JS
const dots = document.querySelectorAll('[data-dots]');
dots.forEach(dot => dot.addEventListener('click', handleClick));
function handleClick(e) {
e.target.getElementsByClassName('tb-drop').classList.toggle('active');
console.log(e.target.getElementsByClassName('tb-drop'))
}
Run Code Online (Sandbox Code Playgroud)
HTML
<div class="dots" data-dots>
<i class="fas fa-ellipsis-v dots"></i>
<div class="tb-drop">
<i class="far fa-edit icon-grid"></i>
<i class="fas fa-link icon-grid"></i>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
所以我选择所有具有 data-dots 属性的 div,然后选择该 div 的子级并添加活动类。我试过 e.target.children 但没有用。
谢谢,我只是想学习:)