Projects built with vue-cli cannot reference regular script tags

as the title, because

<template>
	<div class="third_container">
		<div id="useScript"></div>
		<script type="text/javascript" src="../../../assets/js/alert1.js" ></script>
	</div>
</template>

Directly importing js files with script tags like this will fail to compile, but it can be imported indirectly through js after compilation is complete

mounted(){
        	$("#useScript").html("<script src='../../../assets/js/alert1.js'></srcipt>");
			 this.$nextTick(function(){
			 	setTimeout(function(){
			 		
			 		console.log(suibiandingyi);
			 	},3000);
			 });
        }

During the test, it is unsuccessful without a delay of 3 seconds, because the js should still be loaded, so the variables on this js cannot be obtained.

The test js file code is very simple, as follows

//alert("弹出来有可能可以使用");
console.log("make more time");
var suibiandingyi = "123456"; 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325303676&siteId=291194637