This article shares with you how to use Vue to load weather components for your reference. The specific content is as follows First, we enter the China Weather Network to generate a piece of code Set the weather style as needed Copy and modify the generated code into vue Modify the script import to Vue's dynamic import method <template> <div id="weater"> <div id="weather-view-he" ref="weather"></div> <remote-script src="script src in the weather network generated code"></remote-script> </div> </template> <script> window.WIDGET = {ID: '123456'}; // Add window in front of WIDGET, otherwise this variable cannot be read import Vue from 'vue' Vue.component('remote-script', { // vue dynamically generates script (used as a component in html) render: function (createElement) { var self = this; return createElement('script', { attrs: { type: 'text/javascript', src: this.src }, on: { load: function (event) { self.$emit('load', event); }, error: function (event) { self.$emit('error', event); }, readystatechange: function (event) { if (this.readyState == 'complete') { self.$emit('load', event); } } } }); }, props: { src: { type: String, required: true } } }) export default { name:"Weather", data(){ return { } }, } </script> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Understanding and application analysis of mysql pessimistic locking and optimistic locking
>>: Detailed explanation on how to deploy H5 games to nginx server
Monday to Sunday time format conversion (Y --- ye...
Table of contents Preface 1. Split a string 2. JS...
I started learning MySQL recently. The installati...
Table of contents 1. Preparation before installat...
What is high concurrency? The default Linux kerne...
Verification environment: [root@~~/]# rpm -qa | g...
Table of contents Preface 1. cat command: 2. more...
This article introduces how to create an index on...
Build the image Earlier we used various images fo...
Docker virtualizes a bridge on the host machine. ...
Table of contents 1. Basic Concepts 2. Developmen...
Methods for changing passwords before MySQL 5.7: ...
Table of contents 1.sleep function 2. setTimeout ...
This article describes the MySQL user management ...
This article shares the specific code of Vue to a...