赞
踩
1.响应式
- <script>
- export default {
- data(){
- return{
- message:'hello',
- counter:{
- count:1
- }
- }
- }
- }
- </script>
-
- <template>
- <h1>{{message}}</h1>
- <h1>{{counter.count}}</h1>
- </template>
2.v-bind:缩写成:
- <script>
- export default {
- data() {
- return {
- titleClass: 'title'
- }
- }
- }
- </script>
-
- <template>
- <h1 :class='titleClass'>Make me red</h1>
- </template>
-
- <style>
- .title {
- color: red;
- }
- </style>
3.v-on:缩写成@
- <script>
- export default {
- data() {
- return {
- count: 0
- }
- },
-
- methods:{
- plus(){
- this.count=this.count+1
- }
- }
- }
- </script>
-
- <template>
- <!-- 使此按钮生效 -->
- <button @click='plus'>count is: {{ count }}</button>
- </template>
4.v-model绑定
- <script>
- export default {
- data() {
- return {
- text: ''
- }
- },
- }
- </script>
-
- <template>
- <input v-model='text'>
- <p>{{ text }}</p>
- </template>
5.条件渲染
- <script>
- export default {
- data() {
- return {
- awesome: true
- }
- },
- methods: {
- toggle() {
- this.awesome=!this.awesome
- }
- }
- }
- </script>
-
- <template>
- <button @click="toggle">toggle</button>
- <h1 v-if='awesome'>Vue is awesome!</h1>
- <h1 v-else>Oh no 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/475185推荐阅读
相关标签
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。