Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.0.3 绑定click事件加过滤器后,不能找到绑定的方法! #1656

Closed
rendongsc opened this issue Oct 30, 2015 · 4 comments
Closed
Labels

Comments

@rendongsc
Copy link

以官方的grid示例为列!
1、html代码

<div @click="sortBy(column) | expression column.sortable">

2、自定义过滤器expression代码:

  Vue.filter('expression', function (handler, expression) {
    if (!handler) return;
    if (expression) {
        return function (e) {
            return handler.call(this, e)
        }
    }
});

-------------------------------------报错--------------------------------------------
[Vue warn]: v-on:click="sortBy(column)" expects a function value, got undefined

说明:0.12版本是没有任何问题的!

@yyx990803
Copy link
Member

我帮你把代码格式化了一下,以后能学学 markdown 吗...
还有,请 做成可以直接看的重现,因为你觉得给我这些代码就够了,实际上问题可能出在别的地方。

@285858315
Copy link

“sortBy” 把大写的 B ,改成小写 b。试试 ^_^

@rendongsc
Copy link
Author

改成小写也不行!重现代码写好了,就是网络问题上了http://jsfiddle.net/

@rendongsc
Copy link
Author

尤同学,因网络问题,不能在http://jsfiddle.net/ 呈现,请理解!
测试代码直接在grid示例上修改,修改点如下:
1、data的gridColumns

 gridColumns: [
            {name: 'name', sortable: true},
            {name: 'power', sortable: false}
   ]

2、grid-template模板

  <table>
        <thead>
        <tr>
            <th v-for="col in columns"
            @click="sort(col.name) |expression col.name"
            :class="{active: sortKey == col.name}">
            {{key | capitalize}}
              <span class="arrow"
                    :class="sortOrders[col.name] > 0 ? 'asc' : 'dsc'">
              </span>
            </th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="
            entry in data
            | filterBy filterKey
            | orderBy sortKey sortOrders[sortKey]">
            <td v-for="col in columns">
                {{entry[col.name]}}
            </td>
        </tr>
        </tbody>
    </table>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants