我有一个使用 typescript 的 nextJS 应用程序。我使用 VSCode 进行开发。我注意到,当我打开一个有错误的文件时,VSCode 按预期显示 TS 错误,但eslint事实并非如此。
例如,这是我的 VSCode 错误:
\n\n但这是我的 linting 结果:
\n\xe2\x96\xb6 yarn lint\n\nyarn run v1.22.10\n$ eslint .\n(node:83388) ExperimentalWarning: Conditional exports is an experimental feature. This feature could change at any time\n(node:83388) ExperimentalWarning: Package name self resolution is an experimental feature. This feature could change at any time\n\xe2\x9c\xa8 Done in 5.26s.\nRun Code Online (Sandbox Code Playgroud)\n以下是一些可能有助于识别问题的文件:
\n.eslintrc.js:
\nmodule.exports = {\n plugins: [\n \'@typescript-eslint\',\n ],\n extends: [\n \'airbnb-typescript\',\n \'airbnb/hooks\',\n \'plugin:@typescript-eslint/recommended\',\n \'plugin:@typescript-eslint/recommended-requiring-type-checking\',\n …Run Code Online (Sandbox Code Playgroud) typescript eslint visual-studio-code next.js typescript-eslint
我对这个问题进行了很多搜索,但没有找到直接的答案。我有一个计算属性,它也取决于窗口高度,因此每次调整窗口大小时我都需要重新计算它。尝试过使用$forceUpdate(),但我认为它不适用于组件。这是我的组件:
Vue.component('trades-component', {
mixins: [tradingMixin],
created: function() {
var that = this;
// recompute visible trades if window resized
$( window ).on( "resize", function() {
that.$forceUpdate();
});
$( window ).resize();
},
computed: {
visibleTradesCount: function() {
var colOffset = $(".left-col").offset();
var colHeight = $(".left-col").height();
var tableOffset = $(".left-col #trade-history table").offset();
var tableHeight = colHeight - (tableOffset.top - colOffset.top) - this.rowHeight;
return Math.floor(tableHeight / this.rowHeight)
}
}
})
Run Code Online (Sandbox Code Playgroud)
我知道可能的解决方法,但想知道是否有一种方法可以强制重新计算组件中的特定属性或所有计算属性。