VUE框架CLI组件化开发VUE应用效果------VUE框架
  0AYXapvh7mJh 2023年12月19日 75 0
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
  transpileDependencies: true,
  // 保存时是否进行语法检查,默认为true
  lintOnSave: false,
  // 配置入口
  pages: {
    index: {
      // 默认是main.js
      enrty: 'src/main.js'
    }
  }
})
<template>
    <div>
        <h3>Y1组件</h3>
    </div>
</template>
<script>
    export default {
 
    }
    // 分别导出
    // 默认导出
    // export default y1;
    // 按需导出
</script>
<style>
 
</style>
<template>
   <div>
        <h1>X组件</h1>
        <X1></X1>
   </div>
</template>
<script>
    import X1 from './X1.vue';
    export default {
        components : {X1}
    }
</script>
<style>
 
</style>
<template>
    <div>
        <h3>X1组件</h3>
    </div>
</template>
<script>
    export default {
 
    }
</script>
<style>
 
</style>
<template>
    <div>
        <h1>Y组件</h1>
        <Y1></Y1>
    </div>
</template>
<script>
    import Y1 from './Y1.vue';
    export default {
        // 注册组件
        components : {Y1}
    }
</script>
<style>
 
</style>
<template>
    <div>
        <h1>{{msg}}</h1>
        <x></x>
        <y></y>
    </div>
</template>
<script>
    import X from './components/X.vue';
    import Y from './components/Y.vue';
    export default {
        components : {X,Y},
        data(){
            return {
                msg : "App组件"
            }
        }
    }
</script>
 
<style>
 
</style>
// 这句话就等同于我们写的<script src="vue.js">
// 这就是在引入vue
import Vue from 'vue'
// 然后下一步是导入我们的根组件
import App from './App.vue'
 
// 这是关闭生产提示信息
Vue.config.productionTip = false
 
// 创建VUE实例对象VM
new Vue({
  render: h => h(App),
}).$mount('#app');
// 这里用的是$mount的方式绑定和el的方式是一样的
<!DOCTYPE html>
<html lang="">
  <!-- 在index.html中 -->
  <!-- 没有看到引入main.js文件的原因是Vue脚手架会自动找到main.js文件并引入,不需要手动引入 -->
  <!-- 因此在一般情况下,我们不要轻易修改main.js所在的位置和文件名 -->
  <!-- 如果真的要修改,需要在vue.config里面修改对应的配置信息 -->
  <head>
    <meta charset="utf-8">
    <!-- 让IE浏览器启用最高渲染标准,IE8不支持VUE -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- 开启移动端虚拟窗口(理想视口) -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <!-- 设置页面标签图标 -->
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <!-- 设置标题 -->
    <title><%= htmlWebpackPlugin.options.title %></title>
  </head>
  <body>
    <!-- 当浏览器不支持JS语言的时候,显示如下的信息 -->
    <noscript>
      <strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <!-- VUE管理的容器 -->
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年12月19日 0

暂无评论

推荐阅读
0AYXapvh7mJh