Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 544023d

Browse files
authored
Translate non-node.md via GitLocalize (vuejs#156)
1 parent bcd4c3a commit 544023d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

ja/non-node.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# 非 Node.js 環境における使用
2+
3+
`vue-server-renderer` の標準ビルドは Node.js 環境を想定していますが、これは、[PHP V8Js](https://github.com/phpv8/v8js)[Oracle Nashorn](https://docs.oracle.com/javase/8/docs/technotes/guides/scripting/nashorn/) のような別のJavaScript 環境では使用できなくなります。2.5 のにおいて、環境にはほとんど影響されない、 `vue-server-renderer/basic.js` のビルドを出荷しました。これにより、上記の環境で使用できるようになります。
4+
5+
どちらの環境に対して、それは `global``process` オブジェクトをモックすることによって最初に環境を準備する必要があり、 `process.env.VUE_ENV``"server"` を設定し、そして `process.env.NODE_ENV``"development"` または {code6}"production"{/code6} を設定します。
6+
7+
Nashornでは、Java のネイティブタイマーを使用して、 `Promise{/ code0} または <code data-md-type="codespan">setTimeout` のポリフィルを提供する必要があります。
8+
9+
php-v8js での使用例:
10+
11+
```php
12+
<?php
13+
$vue_source = file_get_contents('/path/to/vue.js');
14+
$renderer_source = file_get_contents('/path/to/vue-server-renderer/basic.js');
15+
$app_source = file_get_contents('/path/to/app.js');
16+
17+
$v8 = new V8Js();
18+
19+
$v8->executeString('var process = { env: { VUE_ENV: "server", NODE_ENV: "production" }}; this.global = { process: process };');
20+
$v8->executeString($vue_source);
21+
$v8->executeString($renderer_source);
22+
$v8->executeString($app_source);
23+
?>
24+
```
25+
26+
---
27+
28+
```js
29+
// app.js
30+
var vm = new Vue({
31+
template: `<div>{{ msg }}</div>`,
32+
data: {
33+
msg: 'hello'
34+
}
35+
})
36+
37+
// `vue-server-renderer/basic.js` によってエクスポーズ
38+
renderVueComponentToString(vm, (err, res) => {
39+
print(res)
40+
})
41+
```

0 commit comments

Comments
 (0)