Blogger Information
Blog 43
fans 4
comment 0
visits 18993
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
VUE安装/VUE基础指令
汇享科技
Original
502 people have browsed it

1.安装VUE

  1. 安装vue需要借助vue脚手架vue cli 安装脚手架需要用到npm或者yarn,mpm安装需要先进行安装node.js

    • nodejs安装地址nodejs.org

    • 安装完成之后可以通过node -v查看是否安装成功
      36800-39oaeiik0jk.png

    • 然后使用npm命令安装脚手架 npm install -g @vue/cli 最新版本的npm不会报错 如果低版本可能会报错可以参考下解决方案

    • 安装脚手架是否成功可以通过vue -V查看
      08118-tstreq0tmp.png

  2. 安装vue 脚手架安装完成之后使用命令vue create 项目名创建项目就OK了

    • 安装之后显示这样的

      57867-p6rv6nvh13r.png

    • 安装完成后可以执行cd目录名 然后启动服务 npm run serve

      16921-z71ehxe85ap.png

2.vue的基础指令

  1. <template>
  2. <!-- 变量显示 -->
  3. <div>{{ huixiang }}</div>
  4. <!-- 双向绑定 -->
  5. <input v-model="huixiang" />
  6. <!-- v-html可以解析html代码 -->
  7. <p v-html="html"></p>
  8. <!-- v-text显示文本 -->
  9. <p v-text="html"></p>
  10. <!-- v-if判断 -->
  11. <div v-if="status == true">汇享</div>
  12. <div v-else>编程</div>
  13. <!-- v-on事件绑定 语法糖@-->
  14. <div @:click="fun">点击切换</div>
  15. <!-- v-bind动态绑定属性 -->
  16. <div :class="green">绿色文字</div>
  17. <!-- v-for 循环 -->
  18. <div>
  19. <ul>
  20. <li v-for="(v, k, index) in users">{{ v }}--{{ k }}--{{ index }}</li>
  21. </ul>
  22. </div>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {
  28. huixiang: "汇享",
  29. html: "<i>你好</i>",
  30. status: false,
  31. green: "green",
  32. users: {
  33. xiaobai: "小白",
  34. xiaohuang: "小黄",
  35. xiaoliu: "小刘",
  36. xiaowang: "小王",
  37. },
  38. };
  39. },
  40. methods: {
  41. fun() {
  42. this.status = !this.status;
  43. },
  44. },
  45. };
  46. </script>
  47. <style scoped>
  48. div {
  49. color: red;
  50. font-size: 30px;
  51. }
  52. .green {
  53. color: green;
  54. }
  55. </style>

61441-keh8a26oli.png

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!