vue3 异步组件例子

vueloader use js

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://updategf.qytechs.cn/scripts/447165/1065325/vue3%20%E5%BC%82%E6%AD%A5%E7%BB%84%E4%BB%B6%E4%BE%8B%E5%AD%90.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Advertisement:

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

Advertisement:

// ==UserScript==
// @name            vue3 异步组件例子
// @namespace       moe.canfire.flf
 
// @description     vueloader use  js
// @author          mengzonefire
// @license         MIT
// @match           *
 
// @grant           GM_setValue
// @grant           GM_getValue
// @grant           GM_deleteValue
// @grant           GM_setClipboard
// @grant           GM_xmlhttpRequest
// @grant           GM_info
// @grant           GM_getResourceText
// @grant           GM_addStyle
// @grant           unsafeWindow
// @run-at          document-start
// @connect         *
// @version 0.0.1.20220314074202
// ==/UserScript==

async function myimport(jsurl,enableCache){
       if(!enableCache) jsurl=jsurl +'?rnd='+Math.random();
        let data = await fetch(jsurl).then(res=>res.text() );
       try{
		 data=data.substr(data.indexOf('{')+0).trim();//
		var json=(new Function("return " + data  ))();
		//自动插入css
		  if( json.css!=undefined ){
                  var style = document.createElement('style');
                  var  head = document.head || document.getElementsByTagName('head')[0]; 
	              style.innerHTML=style.innerHTML+json.css;
                  head.appendChild(style);
		  }///
 		return json;
      }catch (error) { 
           console.log(  jsurl  );
           console.log(    error.name+ error.message );
       }
};//---------------------------

  const app = Vue.createApp({
data:function(){return {
 
 }},//data-----
  methods: {
   
  },//methods-----
  components: {
      test:Vue.defineAsyncComponent(() => myimport("./test.js",false) )
  }
});
   app.use(vant);
   app.use(vant.Lazyload);
  const vm=app.mount('#app');
//////////////////////////////////////
// test.js  //export
 const test = {
    template: `
        这是 <span class=mycss>组件测试</span>
        参数:{{str1}}<br>
    `,
    model: {
      prop: ['str']
    },
    props: {
      str: String
    },
	css:` .mycss{ border:5px solid red;} `
	,
    setup(props) {
      // 在setup里面获取参数值
      const str1 = Vue.ref(props.str)
       return {
        str1
      }
    },
  };