1

我有以下代码:

<template>
    <div>
        <DxDataGrid :dataSource="viewerRoles">
            <DxColumn data-field="name"
                      caption="Ansicht" />
            <DxColumn data-field="description"
                      caption="Beschreibung" />
            <DxColumn type="buttons">
                <DxButton icon="preferences"
                          @click="test" />
            </DxColumn>
        </DxDataGrid>
        <button @click="test"></button>
    </div>
</template>

<script>
    import { DxDataGrid, DxColumn, DxButton } from 'devextreme-vue/data-grid'

    export default {
        name: 'Test',
        components: {
            DxDataGrid, DxColumn, DxButton
        },
        data() {
            return {
                viewerRoles: []
            }
        },
        async created() {
            const svcResp = await this.$http.get('Settings/ViewerRoles');

            if (svcResp.status === 200)
                this.viewerRoles = svcResp.data;
        },
        methods: {
            test() { alert('') }
        }
    }
</script>

奇怪的是,如果我点击 HTML <button>,浏览器会显示警报。但在 上<DxButton>,它没有。据我所知,调试控制台中没有错误。

我的代码有什么问题?

4

1 回答 1

1

DxButton将's更改为@click:on-click因此您的代码应如下所示:

<DxColumn type="buttons">
  <DxButton icon="preferences"
            :on-click="test" />
</DxColumn>
于 2020-10-12T14:04:05.023 回答