1- <script lang="jsx">
1+ <script lang="tsx">
2+ import { defineComponent , ref , watch } from ' vue'
23import { RecycleScroller } from ' vue-virtual-scroller'
34import ' vue-virtual-scroller/dist/vue-virtual-scroller.css'
45
5- const InnerInput = {
6+ const InnerInput = defineComponent ( {
67 name: ' InnerInput' ,
78 props: [' value' , ' readOnly' ],
8- data() {
9- return {
10- val: null,
11- }
12- },
13- watch: {
14- value(val) {
15- this.val = val
16- },
17- },
18- created() {
19- this.val = this.value
20- },
219 emits: [' change' ],
22- render() {
23- return (
10+ setup(props , { emit }) {
11+ const val = ref (props .value )
12+ watch (
13+ () => props .value ,
14+ (newVal ) => {
15+ val .value = newVal
16+ },
17+ )
18+ return () => (
2419 <input
25- class="name-list-item-input px-2 rounded-4 "
26- readOnly={this .readOnly}
27- value={this. val}
28- onChange={(ev) => this.$ emit('change', ev)}
20+ class = " name-list-item-input px-2 rounded-lg "
21+ readonly = { props .readOnly }
22+ value = { val . value }
23+ onChange = { (ev ) => emit (' change' , ev )}
2924 />
3025 )
3126 },
32- }
27+ })
3328
3429export default {
3530 name: ' List' ,
3631 components: { RecycleScroller , InnerInput },
3732 props: [
33+ ' items' ,
3834 ' nameMap' ,
3935 ' tableData' ,
4036 ' updateName' ,
@@ -71,8 +67,14 @@ export default {
7167 </script >
7268
7369<template >
74- <RecycleScroller v-bind =" $attrs " >
75- <template #default =" { item: name } " >
70+ <RecycleScroller
71+ v-bind =" $attrs "
72+ :items =" items "
73+ key-field="name"
74+ :item-size =" 38 "
75+ :buffer =" 50 "
76+ >
77+ <template #default =" { item: { name } } " >
7678 <div class =" name-list-item flex align-center position-relative" >
7779 <div class =" flex-1 px-4 text-truncate" >
7880 <span :title =" name" >{{ name }}</span >
@@ -92,12 +94,6 @@ export default {
9294 } "
9395 @change =" handleChange (name , $event )"
9496 />
95- <!-- <input
96- class="name-list-item-input px-2"
97- :readOnly="disabled"
98- :value="nameMap[name] || name"
99- @change="handleChange"
100- />-->
10197 </div >
10298 <VIcon size="12" class="name-list-item-center font-color-light">
10399 left
0 commit comments