美文网首页
vue中如何给computed的值传参

vue中如何给computed的值传参

作者: wait_cynthia | 来源:发表于2018-12-26 21:58 被阅读0次

把需要computed的值返回一个带参数的函数即可给computed传参

html 代码

  <div>{{ count(3) }}</div> // 显示 4

vue 代码

  computed: {
    count: {
      return function (index) {
         return index + 1
      }
    }
  }

相关文章

  • vue中如何给computed的值传参

    把需要computed的值返回一个带参数的函数即可给computed传参 html 代码 vue 代码

  • vue中计算属性computed方法内传参

    原文:vue中计算属性computed方法内传参 vue中computed计算属性无法直接进行传参 如果有传参数的...

  • Vue踩过的坑

    NO.1 vue中的计算属性computed是不能传参的,只能通过变通的方法 比如:{{getUserNames(...

  • vue通过computed传参

    template js

  • vue面试常见问题

    vue中动态绑定class的方式? watch和computed的区别 vue中key的作用 vue父传子 子传父...

  • vue computed属性传值

    html js

  • vue组件传参问题

    在vue项目中会经常遇到组件传参问题,今天就来了解一下父子组件和兄弟组件传参 父组件传值给子组件 *父组件通过 ...

  • Vue动态修改title

    index.vue => game.vue 修改 heade中的title 用router传参的形式给 ga...

  • computed传参

    在特有的需要对两个数组循环进行比较判断,但是又不能同时使用v-for和v-if,这时候就可以使用computed。...

  • 31.vue传参

    1.vue传参 vue传参使用路由传参params,query,或者使用vuex,localStorage,vue...

网友评论

      本文标题:vue中如何给computed的值传参

      本文链接:https://www.haomeiwen.com/subject/ayxokqtx.html