Blogger Information
Blog 47
fans 0
comment 0
visits 21013
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
vue的基本用法
P粉036614676
Original
356 people have browsed it

1.Vue安装

  1. //打开服务器
  2. yarn serve
  3. npm run serve
  4. ctrl + c :停止服务器

目录名 作用
node_modules npm 加载的项目依赖模块
public 公共资源目录
src 开发目录
src/main.js 主入口文件
src/App.vue 网站首页文件
src/assete 存放静态资源:css、js、字体、图片、资源
src/components 存放通用模块组件
src/router 存放路由设置文件
src/views
babel.config.js
package.json
package-lock.json
README.md


static 静态资源目录,如图片、字体等
dist 打包后会生成该的目录
build 项目构建(webpack)相关代码

2、Vue 基本语法

  1. <!--
  2. Vue.js中就三种标签
  3. 1. <template></template>
  4. 2. <script></script>
  5. 3.<style></style>
  6. -->
  7. <!-- <template>
  8. <div>
  9. <div v-pre>{{ htmlcode }}</div>
  10. </div>
  11. </template>
  12. <script>
  13. export default {
  14. data() {
  15. return {
  16. htmlcode: "<h1 style='color:red;'>欧阳克</h1>"
  17. };
  18. }
  19. };
  20. </script> -->
  21. <template>
  22. <div class="first" >{{name1 + name2}}</div>
  23. <p>{{ret()}}</p>
  24. <p v-text="name1"></p>
  25. <p v-html="html"></p>
  26. <!-- <p v-pre="htmlx"></p> -->
  27. <input type="text" v-model="myname">
  28. <input type="text" v-bind:value="myname">
  29. <p v-text="myname"></p>
  30. <a href=""></a>
  31. <input type="text" v-model="myname">
  32. </template>
  33. <script>
  34. export default{
  35. data(){
  36. return {
  37. name1:'aaa',
  38. name2:'bbb',
  39. value:100,
  40. html:'<p>asdasd</p>',
  41. input:'asd',
  42. htmlx:'<h1>sad</h1>',
  43. myname:'null'
  44. }
  45. },
  46. methods:{
  47. ret()
  48. {
  49. this.name1 ='ccc';
  50. }
  51. }
  52. }
  53. </script>
  54. <style>
  55. .clore
  56. {
  57. background-color: red;
  58. }
  59. </style>
  1. <template>
  2. <!-- <a href="http://baidu.com" @click.prevent="fun1()">显示</a>
  3. <div v-on:click.stop="fun1()">父亲
  4. <div @click.stop="fun1()">儿子</div>
  5. </div> -->
  6. <!-- <p>{{count}}</p>
  7. <button @click="fun2($event)">点击</button> -->
  8. <input type="text" v-on:input="fun3($event)">
  9. <!-- <p>{{value}}</p> -->
  10. <!-- <p v-if="value == 1">1</p>
  11. <p v-else-if="value == 2">2</p>
  12. <p v-else>3</p> -->
  13. <ul>
  14. <li v-for="(v,k,index) in arr">{{v}} == {{k}}</li>
  15. </ul>
  16. </template>
  17. <script>
  18. export default({
  19. data(){
  20. return {
  21. count:1,
  22. value:1
  23. }
  24. },
  25. methods:{
  26. fun1(){
  27. console.log('click');
  28. },
  29. fun2(event)
  30. {
  31. this.count++
  32. },
  33. fun3(event)
  34. {
  35. this.value = event.data;
  36. }
  37. }
  38. })
  39. </script>
  40. <style>
  41. </style>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post