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
Currently, almost all large websites and applicat...
I have learned some basic selectors of CSS before...
Mixins provide distributed reusable functionality...
First method : CSS code: Copy code The code is as ...
1. Use the transform attribute to display the ima...
background We can use react-color to implement th...
1. Construction 1. Prepare htpasswd.txt file The ...
Table of contents View all storage engines InnoDB...
Business scenario: Use vue + element ui's el-...
Table of contents 1. Docker Image 2. Create an in...
The MySQL query result row field splicing can be ...
today select * from table name where to_days(time...
MyISAM storage engine The MyISAM storage engine i...
For example, if I have a Jenkins server in my int...
Common methods for limiting input 1. To cancel the...