yaowen

App.vue

<template>
  <div id="app">
    <h3>welcome vue-loading</h3>
    <Loading></Loading>    <!--<Loading></Loading>是自定义组件--> 
</div>
</template>

main.js

import Vue from \'vue\'
import App from \'./App.vue\'

import Loading from \'./components/loading\'  //定义Loading,components、loading是一个文件夹,loading里面必须要index.js

Vue.use(Loading)    //use Loading

new Vue({
    el: \'#app\',
    render: h => h(App)
})

index.js

import LoadingComponent from \'./Loading.vue\'

const Loading = {     //定义Loading
    install: function(Vue) {//install是必须的
        Vue.component(\'Loading\', LoadingComponent)//定义一个组件
    }
};

export default Loading

Loading.vue

<template>
    <div class="loading-box">
        {{msg}}
    </div>
</template>
<script>
    export default{
        data(){
            return {
                msg:\'Loading...^_^\'
            }
        }
    }
</script>
<style scoped>
    .loading-box{
        color: red;
        font-size: 40px;
        font-family: 微软雅黑;
        text-shadow: 2px 2px 5px #000;
    }
</style>

 

分类:

技术点:

相关文章:

  • 2021-08-24
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2021-11-02
  • 2021-06-01
  • 2021-08-04
  • 2021-10-18
猜你喜欢
  • 2021-12-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-30
  • 2022-12-23
相关资源
相似解决方案