3.0.0-beta.6
https://jsfiddle.net/yozman/3Lcwjrts/
vue.config.js
$slots.default 去掉空格
$slots.default 空格一直存在
感觉是 vueLoader 的 preserveWhitespace 未生效
Tested, and it's working with or without vue.config.js.🤔
@jkzing
r u sure?
$slots.default.length 一直是包含空格的
@yozman Yes, from what I'm seeing, preserveWhitespace is working as expected.
Maybe you could provide your problematic code (like a github repo) to help reproduce the issue.
@jkzing
I use .js without .vue
// parent.js
import Child from './child';
const template = /*html*/`
<child>
<h1>one</h1>
<h1>two</h1>
</child>
`;
export default {
template,
components: {
Child,
},
};
// child.js
const template = /*html*/`
<div>
<slot/>
</div>
`;
export default {
template,
created() {
console.log(this.$slots.default.length);
},
};
Well, if you use js files, then you are not using vue-loader, which only takes care of .vue files.
Inline JS strings are compiled by the runtime compiler, not vue-loader.
@yyx990803 @LinusBorg
how can I set preserveWhitespace to runtime compiler?
is there any way except directly
// ...
export default {
render: () => Vue.compile(template, {
preserveWhitespace: false,
}),
};
maybe there should be a way to set preserveWhitespace like Vue.config
@yyx990803 @LinusBorg
could u please give a solution?
This would have to be addressed in the vue repository, not here.
Toy should open a feature request over there and explain the use case.
@yozman you cannot. If you want that behavior you have to use pre-compile via vue-loader.
@yyx990803 why don't u make a feature to that, as every FE known everything is js, not .vue
@yyx990803 why don't u make a feature to that, as every FE known everything is js, not
.vue
yes, inline template need preserve whitespace between tags. @yyx990803
https://codepen.io/sunchanglong/pen/YgpmKV?editors=1111

Most helpful comment
@yyx990803 why don't u make a feature to that, as every FE known everything is js, not
.vue