classCardComponentextendsHTMLElement { constructor (){ super(); const shadow = this.attachShadow({mode: 'open'}); // Clone the template so that it can be attched to the shadowroot const template = document.getElementById('card-view'); const templateInstance = template.content.cloneNode(true); shadow.appendChild(templateInstance); } }
constAPI_KEY = '*YOUR_API_KEY*'; const url = `http://api.giphy.com/v1/gifs/trending?api_key=` + API_KEY + `&limit=1`; export {API_KEY, url}; // export the url so that i can be used extrnally.
<script> const main = document.querySelector("main"); for (const link of document.querySelectorAll("nav > a")) { link.addEventListener("click", e => { e.preventDefault();
React社区中提供了类似create-react-app这样的命令行工具,作为React项目的脚手架,这个工具提供了大而全的功能,直接拿过来使用,你可能不明白背后的原理,这里跟着Creating a React App… From Scratch这篇文章一起从零搭建一个React App,有条件的同学可以直接阅读英文版,这里实现的是一个最简单的功能,支持ES6+和JSX语法、热加载。
HTTP is a protocol which allows the fetching of resources, such as HTML documents. Clients and servers communicate by exchanging individual messages(as opposed to stream of data).The messages sent by the client, usually a Web browser, are called requests and the messages sent by server as an answer are called responses.