@template-productlist-id = 1;
& when (@template-productlist-id = 0) {
import "product-lists/product-list0.less";
}
& when (@template-productlist-id > 0) {
import "product-lists/product-list.less";
}
但它似乎并没有起作用。仍然导入2个文件。我怎样才能做到这一点?
答案 0 :(得分:1)
您的代码无效,请尝试:
:
)@
)
@template-productlist-id: 0;
.import() {
& when (@template-productlist-id = 0) {
@import "product-lists/product-list0.less";
}
& when (@template-productlist-id > 0) {
@import "product-lists/product-list.less";
}
}
.import();
或者下面的Less代码也会给出预期的结果:
@template-productlist-id: 0;
& when (@template-productlist-id = 0) {
@import "product-lists/product-list0.less";
}
& when (@template-productlist-id > 0) {
@import "product-lists/product-list.less";
}