自定义工具未显示视图,Laravel Nova

时间:2018-10-18 13:55:00

标签: php laravel laravel-nova

我只是按照所有步骤制作了一个自定义工具Laravel/Nova/custom/tools,但是它没有显示默认视图,没有控制台错误(js)或php错误,但是该视图为空。   enter image description here

 

    namespace Mihrbi\CompanyConfig;

    use Laravel\Nova\Nova;
    use Laravel\Nova\Tool;

    class CompanyConfig extends Tool
    {
        /**
         * Perform any tasks that need to happen when the tool is booted.
         *
         * @return void
         */
        public function boot()
        {
            // Nova::script('company-config', __DIR__.'/../dist/js/tool.js');
            // Nova::style('company-config', __DIR__.'/../dist/css/tool.css');
            Nova::serving(function (ServingNova $event) {
                Nova::script('company-config', __DIR__.'/../dist/js/tool.js');
                Nova::style('company-config', __DIR__.'/../dist/css/tool.css');
            });
        }

        /**
         * Build the view that renders the navigation links for the tool.
         *
         * @return \Illuminate\View\View
         */
        public function renderNavigation()
        {
            return view('company-config::navigation');
        }
    }

这是我为使用Nova :: serving进行的唯一更改,以避免出现“ nova-api / scripts / company-config 500(内部服务器错误)”

enter image description here

当我删除Nova :: serving和npm run prod时会发生这种情况

local.ERROR:file_get_contents(/ home / site / nova-components / CompanyConfig / src /../ dist / css / tool.css):无法打开流:没有此类文件或目录

这是我的package.json

{
"private": true,
"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
    "cross-env": "^5.0.0",
    "laravel-mix": "^1.0"
},
"dependencies": {
    "vue": "^2.5.0"
}

}

1 个答案:

答案 0 :(得分:0)

删除Nova::serving行,并在工具的根目录中运行npm run prod,以便它在dist文件夹中发布JS和CSS文件