深圳全飞鸿

标题: Vue一个空项目的目录结构和内容 [打印本页]

作者: syant    时间: 2024-7-27 19:42
标题: Vue一个空项目的目录结构和内容
App.vue
  1. <template>
  2.   <div id="app">
  3.     <img alt="Vue logo" src="./assets/logo.png">
  4.     <HelloWorld msg="Welcome to Your Vue.js App"/>
  5.   </div>
  6. </template>

  7. <script>
  8. import HelloWorld from './components/HelloWorld.vue'

  9. export default {
  10.   name: 'App',
  11.   components: {
  12.     HelloWorld
  13.   }
  14. }
  15. </script>

  16. <style>
  17. #app {
  18.   font-family: Avenir, Helvetica, Arial, sans-serif;
  19.   -webkit-font-smoothing: antialiased;
  20.   -moz-osx-font-smoothing: grayscale;
  21.   text-align: center;
  22.   color: #2c3e50;
  23.   margin-top: 60px;
  24. }
  25. </style>
复制代码



作者: syant    时间: 2024-7-27 19:43
main.js
  1. import Vue from 'vue'
  2. import App from './App.vue'

  3. Vue.config.productionTip = false

  4. //h是createElement的别名
  5. new Vue({
  6.   render: h => h(App),
  7. }).$mount('#app')
复制代码

作者: syant    时间: 2024-7-27 19:44
components/HelloWorld.vue
  1. <template>
  2.   <div class="hello">
  3.     <h1>{{ msg }}</h1>
  4.   </div>
  5. </template>

  6. <script>
  7. export default {
  8.   name: 'HelloWorld',
  9.   props: {
  10.     msg: String
  11.   }
  12. }
  13. </script>

  14. <!-- Add "scoped" attribute to limit CSS to this component only -->
  15. <style scoped>
  16. h1 {
  17.   margin: 40px 0 0;
  18. }
  19. </style>
复制代码

作者: syant    时间: 2024-7-27 20:16
①        内容渲染指令        v-text="message"、{{ message }}、v-html="message"
②        属性绑定指令        v-bind:value="message" 简写用冒号:value="message"
③        事件绑定属性        v-on:click 简写用@click
④        双向绑定指令        v-model="message"
⑤        条件渲染指令        v-if="true"移除元素 v-show="false"修改display:none
⑥        列表渲染指令        v-for="(item,index) in list"

作者: syant    时间: 2024-7-27 20:16
①        内容渲染指令        v-text="message"、{{ message }}、v-html="message"
②        属性绑定指令        v-bind:value="message" 简写用冒号:value="message"
③        事件绑定属性        v-on:click 简写用@click
④        双向绑定指令        v-model="message"
⑤        条件渲染指令        v-if="true"移除元素 v-show="false"修改display:none
⑥        列表渲染指令        v-for="(item,index) in list"





欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2