【问题标题】:Route is not defined?路由没有定义?
【发布时间】:2018-12-07 04:36:03
【问题描述】:

我有以下代码:

data: function(row, type, val, meta) {
    return tmpl('<%if(slug){%><a href="<%=route("url-show-event", slug)%>"><%=title%></a><%}else{%>-<% } %>', row);
    },

它是数据表 ajax 调用的一部分。

问题是我得到了这个错误:

Uncaught ReferenceError: route is not defined

我已经上传到我的服务器并且可以正常工作,但不是在本地主机中

所以我已经从 Laravel 中删除了所有供应商并安装和更新,但我仍然遇到同样的错误。

有什么想法吗?

【问题讨论】:

  • 您使用的是哪个版本?
  • Laravel 5.5.40 在服务器和本地主机中
  • url-show-event 存在吗?请发布您的路线
  • Route::get('/entradas-{slug}/{token?}', 'EventsController@show')->name('url-show-event');
  • 问题是它在生产中正常工作,但在本地主机中却没有,相同的代码,相同的数据库,所以这很奇怪,这就是为什么我尝试使用 composer install 来查看问题是否与供应商有关。另一种选择是在 localhost 中路由被区别对待

标签: json ajax laravel


【解决方案1】:

老大,试试这个 php artisan view:clear, 有时候有帮助

【讨论】:

    【解决方案2】:
    php artisan config:clear
    
    php artisan route:clear
    
    php artisan cache:clear
    

    当您有缓存路由时可能会发生这种情况。清除缓存,然后重试。

    【讨论】:

      猜你喜欢
      • 2017-09-08
      • 2016-04-29
      • 1970-01-01
      • 1970-01-01
      • 2018-09-13
      • 1970-01-01
      • 2021-05-03
      • 2017-10-30
      • 1970-01-01
      相关资源
      最近更新 更多