页面代码:
<template>
<div >
============================流星雨============================
<div class="title">
<div id="stars"></div>
</div>
</div>
</template>
<script>
import "./css/style.css"
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
},
mounted(){
this.shootingStar();
},
methods:{
shootingStar: function () {
let stars = document.getElementById('stars')
let star = document.getElementsByClassName('star')
// js随机生成流星
for (let j = 0; j < 30; j++) {
let newStar