我有6个"块",每个包含不同的文本,为了简单起见,我们只考虑这些作为我的"块"
<div id="block1"> <h2> Block1 </h2> </div
Run Code Online (Sandbox Code Playgroud)
我有3个可见,3个隐藏.我有一个按钮,可以替换相应的块
$(".showmore").click(function(){
$("#block1").fadeOut("slow", function(){
$(this).replaceWith($("#block4").html());
$(this).fadeIn("slow");
});
$("#block2").delay(400).fadeOut("slow", function(){
$(this).replaceWith($("#block5").html());
$(this).fadeIn("slow");
});
$("#block3").delay(800).fadeOut("slow", function(){
$(this).replaceWith($("#block6").html());
$(this).fadeIn("slow");
});
$(this).text('Show less');
});
Run Code Online (Sandbox Code Playgroud)
它工作正常,但不知道如何还原它.我试图将元素克隆到变量然后加载它们但似乎id已经消失,因为当我试图隐藏block1或block4时,它们都没有消失.有人可以帮忙吗?
我已将 安装eslint-plugin-import到我的项目中,我的目标是使用该'import/no-relative-parent-imports': 'error'设置来禁止我的项目中的相对导入以提高可读性。
但是,此设置会在我的项目中产生错误,因为它不会将我的 tsconfig 别名提取到根文件夹。
我的tsconfig.json有以下设置。
"paths": {
"src/": ["./src/*"]
}
Run Code Online (Sandbox Code Playgroud)
我尝试通过以下方式在我的项目中导入组件。
import { Component } from 'src/components/ComponentA'但是随后 eslint 抱怨使用相对导入,而实际上我在 tsconfig 路径别名的帮助下绝对导入了我的组件。我已经安装eslint-import-resolver-typescript并在我的.eslintrc.js文件中启用了它。
settings: {
'import/resolver': {
typescript: {},
},
},
Run Code Online (Sandbox Code Playgroud)
我的错误信息如下。
Relative imports from parent directories are not allowed. Please either pass what you're importing through at runtime (dependency injection), move `example.ts` to same directory as `src/components/ComponentA` or consider making `src/components/ComponentA` a package. (eslintimport/no-relative-parent-imports)
Run Code Online (Sandbox Code Playgroud)