Blogger Information
Blog 27
fans 1
comment 2
visits 90421
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
Vue路由和Vue组合api
          
Original
430 people have browsed it
  1. <template>
  2. <router-view></router-view>
  3. <router-link to="/">首页 </router-link>
  4. <router-link to="about"> 关于我们</router-link>
  5. <router-link to="php"> PHP页面</router-link>
  6. <router-link to="user"> 用户页面</router-link>
  7. <div>
  8. 变量:{{name}}
  9. <hr>
  10. 方法:<button @click="fun()"> 点击</button>
  11. <hr>
  12. 点击计数:<button @click="fun2()">{{num}}</button>
  13. </div>
  14. <hr>
  15. <h4>引入组件,组件包含小组件</h4>
  16. <phpxiaojimu></phpxiaojimu>
  17. </template>
  18. <!--组合式Api-->
  19. <script setup>
  20. // reactive,ref 把数据转为响应式
  21. import {reactive,ref} from "vue";
  22. // 引入组件
  23. import phpxiaojimu from './components/php.vue'
  24. let name = '隔壁老王';
  25. const fun =()=>{
  26. alert('点击了方法!')
  27. };
  28. let num = ref(0)
  29. // 点击进行累加2方法
  30. const fun2 = ()=>{
  31. console.log(num)
  32. num.value += 2;
  33. }
  34. // 使用组件:components
  35. components :{
  36. phpxiaojimu
  37. }
  38. </script>
  39. <style >
  40. .red {
  41. color: red;
  42. }
  43. </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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!