课程: Hands-On Introduction: JavaScript
免费学习该课程!
今天就开通帐号,24,700 门业界名师课程任您挑!
Make a component reusable through nesting - JavaScript教程
课程: Hands-On Introduction: JavaScript
Make a component reusable through nesting
- [Instructor] Modern JavaScript is component-based, meaning instead of having one giant JavaScript file where everything is happening, we split out each part of the JavaScript file into a separate component and pull it in only when we're using it. This practice became commonplace with JavaScript frameworks like React and Vue, and has now been brought over to JavaScript proper, so we can use components in regular JavaScript files. In JavaScript, we usually call them modules. And you can see here, when I call in script.js in the index file, I also say type=module. This is what allows us to import content into script.js and relate JavaScript files to one another. It's what you see up here. In script.js, remember we call in the data from data.js. That's made possible because we've componentized the JavaScript by creating JavaScript modules. In between the previous movie and this one, I've applied a componentized approach…