我正在構建一個Vue JS SPA,并且在v-app內部有一個Vuetify數據表。我正在嘗試在監視對象內為數據表內的filteredItems計算屬性設置一個變量,但是我不確定如何訪問實例內的$ refs數組。我知道可以使用以下方法在實例內訪問數據:this.$refs['prospectsTable'].filteredItems但是,相同的引用名稱在watch對象中不起作用。我試過了:$refs['prospectsTable'].filteredItems: function(newItems) { console.log(newItems); }&this.$refs['prospectsTable'].filteredItems: function(newItems) { console.log(newItems); }我如何訪問watch函數內部的$ refs數組?var p = new Vue({ el: '#prospectsApp', data: () => ({}), watch: function() { // How can i access the $refs array inside of the watch function? $refs['prospectsTable'].filteredItems: function() { } }});<div id="prospectsApp"> <v-app id="inspire" v-cloak> <v-data-table ref="prospectsTable" v-model="selected" :headers="headers" :items="prospects" :pagination.sync="pagination" select-all item-key="id" class="elevation-1" > <template v-slot:headers="props"> <tr> <th><v-checkbox :input-value="props.all" color="#c79121" :indeterminate="props.indeterminate" primary hide-details @click.stop="toggleAllSelected"></v-checkbox></th> <th v-for="header in props.headers" :key="header.text" :class="['column sortable', pagination.descending ? 'desc' : 'asc', header.value === pagination.sortBy ? 'active' : '']" @click="changeSort(header.value)"> <v-icon small>arrow_upward</v-icon> @{{ header.text }} </th> </tr> </template> </td> </tr> </template> <template slot="no-data"> <p class="text-xs-center">No Data</p> </template> </v-data-table> </v-app></div>
訪問Vue JS實例監視對象內的$ refs數組
qq_遁去的一_1
2021-03-30 13:14:10