如何在Vue.js中声明组件方法和过滤器参数的类型?我不断收到如下错误:
client:167 (undefined) [at-loader] ./src/components/rating-tile/RatingTile.ts:37:42
TS7006: Parameter 'iconStyle' implicitly has an 'any' type.
作为参考,以下是引发该错误的过滤器:
Vue.filter('getIconPath', function (str, iconStyle) {
return require('./assets/' + str + iconStyle + '.png')
});
答案 0 :(得分:0)
您需要在参数中添加类型注释,例如:
Vue.filter('getIconPath', function (str: string, iconStyle: string) {
return require('./assets/' + str + iconStyle + '.png')
});