TS7006: Parameter 'props' implicitly has an 'any' type.
$ npm run build
...
./download.vue:22:11 - error TS7006: Parameter 'props' implicitly has an 'any' type.
22 setup(props, ctx) {
~~~~~
./download.vue:22:18 - error TS7006: Parameter 'ctx' implicitly has an 'any' type.
22 setup(props, ctx) {
~~~
Found 2 errors in the same file, starting at: src/components/download/download.vue:22
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
编译失败,问题原因是没有按照标准方法导出模块,需要将要导出的整个对象包装在defineComponent
方法中。修改如下:
<script lang="ts">
import { reactive, toRefs, defineComponent } from 'vue'
// import { props } from './props'
export default defineComponent({
props: {
icon: {
type: String,
default: 'download',
},
content: {
type: String,
default: 'download',
},
},
emits: ['resolve'],
setup(props, ctx) {
const state = reactive({
icon: props.icon,
content: props.content,
})
// 点击事件
const resolve = () => {
ctx.emit('resolve')
}
return { resolve, ...toRefs(state) }
},
})
</script>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29