<?php
namespace App\Http\Controllers\Auth;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Model\User;
use Illuminate\Support\Facades\Auth;
use Socialize;
use Redirect;
use Input;
use Mail;
use App\Mail\verifyEmail;
use Carbon\Carbon;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Facades\File;
class CustomAuthController extends Controller
{
// Register form
private function render() {
$renderer_source = File::get(base_path('node_modules/vue-server-renderer/basic.js'));
$app_source = File::get(public_path('js/entry-server.js'));
$v8 = new \V8Js();
ob_start();
$v8->executeString('var process = { env: { VUE_ENV: "server", NODE_ENV: "production" }}; this.global = { process: process };');
$v8->executeString($renderer_source);
$v8->executeString($app_source);
return ob_get_clean();
}
public function get() {
$ssr = $this->render();
return view('app', ['ssr' => $ssr]);
}
}
我跟着https://dzone.com/articles/server-side-rendering-with-laravel-amp-vuejs-25并安装了 v8js。但错误是 $v8->executeString($app_source); 出错“V8Js::compileString():9272: ReferenceError: window is not defined”
如何修复这个错误。我不知道
=================================================
更新我可以运行它。我通过删除更改 app.js 中的代码
/** after i delete it.i can run with server side rendering
require('./bootstrap');
require('./bulma-carousel.min')
window.Vue = require('vue');
can you tell me why ?*/
import App from './components/App.vue';
import VeeValidate from 'vee-validate';
import Vue from 'vue';
import router from './router'
Vue.use(VeeValidate);
/**
* Next, we will create a fresh Vue application instance and attach it to
* the page. Then, you may begin adding components to this application
* or customize the JavaScript scaffolding to fit your unique needs.
*/
Vue.component('index-component', require('./components/index.vue'));
export function createApp() {
return new Vue({
render: h => h(App)
});
}