現在、SSRディレクティブは、使用される(サブ)コンポーネントには適用されず、HTMLタグと要素にのみ適用されます。
// Step 1: Create a Vue instance
const Vue = require("vue");
const Test = {
template: `<div>This should be red</div>`
}
const app = new Vue({
template: `
<div>
<Test v-make-red/>
<div v-make-red>This is red</div>
</div>
`,
components: {
Test
}
});
const makeRed = (node, dir) => {
const style = node.data.style || (node.data.style = {});
if (Array.isArray(style)) {
style.push({ backgroundColor: "red" });
} else {
style.backgroundColor = "red";
}
};
// Step 2: Create a renderer
const renderer = require("vue-server-renderer").createRenderer({
directives: {
makeRed
}
});
// Step 3: Render the Vue instance to HTML
renderer.renderToString(app, (err, html) => {
if (err) throw err;
console.log(html);
// <div data-server-rendered="true"><div>This should be red</div> <div style="background-color:red;">This is red</div></div>
// But should include red background-color style for the first div as well
});
関連: https :
やあみんな。 私は毎日vueを使用しており、貢献したいと思っています。 これは貢献ウェルカムラベルです。
誰かが私を助けてくれるので、可能であればこれを修正し始めることができますか?
(私はすでにフォークインストールされており、テストとビルドを実行できます。)
こんにちは、これに関する更新はありますか? まだnuxt2.14で動作していません
こんにちは、これに関する更新はありますか? まだnuxt2.14で動作していません
+1
まだ動かない、
[email protected]
[email protected]
[email protected]
最も参考になるコメント
やあみんな。 私は毎日vueを使用しており、貢献したいと思っています。 これは貢献ウェルカムラベルです。
誰かが私を助けてくれるので、可能であればこれを修正し始めることができますか?
(私はすでにフォークインストールされており、テストとビルドを実行できます。)