对于我的管理面板,我提取所有资产,包括manifest-json.jsto mix.setPublicPath(path.normalize('public/backend/')).
所有文件都正确添加到后端文件夹,manifest-json.js文件如下所示:
{
// all correct here
"/js/vendor.js": "/js/vendor.js",
"/js/app.js": "/js/app.js",
"/css/app.css": "/css/app.css",
"/js/manifest.js": "/js/manifest.js"
}
Run Code Online (Sandbox Code Playgroud)
问题是在使用时
{{ mix('backend/css/app.css') }}
Run Code Online (Sandbox Code Playgroud)
在我的刀片文件中,它看起来public/manifest-json.js而不是寻找它backend/manifest-json.js.
如何确保使用正确的manifest-json.js文件?
我很难使用Laravel Mix和DataTables。我遇到的问题是,当我编译.js文件等时,每次我随后访问执行jQuery数据表的页面时,都会引发以下错误:
错误是:
jQuery.Deferred exception: $(...).DataTable is not a function TypeError: $(...).DataTable is not a function
Uncaught TypeError: $(...).DataTable is not a function
Run Code Online (Sandbox Code Playgroud)
据我了解,$(...).DataTable它不是全局变量,但是如何确保可以在应用程序中“在全局范围内”访问它?
以下是我的设置:
app.js
import jquery from 'jquery/dist/jquery.slim'
import 'bootstrap-sass'
import 'datatables.net';
import dt from 'datatables.net-bs';
window.$ = window.jQuery = jquery;
Run Code Online (Sandbox Code Playgroud)
webpack.mix.js
mix
.js('resources/assets/admin/js/app.js', 'js/')
.extract([
'jquery', 'bootstrap-sass', 'datatables.net', 'datatables.net-bs'
])
.autoload({
jquery: ['$', 'window.jQuery', 'jQuery', 'jquery'],
DataTable : 'datatables.net-bs'
})
Run Code Online (Sandbox Code Playgroud)
任何想法将不胜感激。
我目前在我的Mix文件中尝试使用多个入口点时遇到问题.
// Mix frontend resources.
mix.js('resources/assets/js/app.js', 'public/js')
.extract([
'jquery', 'bootstrap', 'aos', 'lity',
]);
...
// Mix app resources.
mix.js('resources/assets/app/js/app.js', 'public/app/js');
Run Code Online (Sandbox Code Playgroud)
我的Mix文件中有三个入口点.一个用于前端,后端和我的"公共应用"文件.上面的代码将我的前端vendor.js和manifest.js文件存储public/app/js在里面public/js.
当我然后尝试参考
<script src="{{ mix('js/manifest.js') }}"></script>
<script src="{{ mix('app/js/app.js') }}"></script>
Run Code Online (Sandbox Code Playgroud)
它抛出webpack错误:
Uncaught TypeError: Cannot read property 'call' of undefined
at __webpack_require__ (manifest.js?id=09ecc9b…:55)
at Object../node_modules/vue/dist/vue.common.js (app.js?id=6431fd7…:sourcemap:28709)
at __webpack_require__ (manifest.js?id=09ecc9b…:55)
at Object../resources/assets/app/js/app.js (app.js?id=6431fd7…:sourcemap:37900)
at __webpack_require__ (manifest.js?id=09ecc9b…:55)
at Object.0 (app.js?id=6431fd7…:sourcemap:38015)
at __webpack_require__ (manifest.js?id=09ecc9b…:55)
at webpackJsonpCallback (manifest.js?id=09ecc9b…:26)
at app.js?id=6431fd7…:sourcemap:1
Run Code Online (Sandbox Code Playgroud)
目前有一种方法可以在Mix文件中使用多个入口点吗?
我目前在一个存储在函数内的数组中存储了一些jQuery片段.一旦我从我的代码库调用该函数,就会执行每个jQuery代码段.因此,阻止我通过阵列.
以下代码是一个示例:
var remove = [
jQuery("#mesh option:selected").removeAttr("selected"),
jQuery("#pipetype option:selected").removeAttr("selected"),
jQuery("#caboption option:selected").removeAttr("selected"),
jQuery("#bedsize option:selected").removeAttr("selected"),
jQuery("#model option:selected").removeAttr("selected"),
jQuery("#year option:selected").removeAttr("selected"),
];
for (var i = 0; i <= amount; i++) {
remove[i];
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能确保在deselect()调用时,只有少数数组元素被执行而不是全部执行?
谢谢!
我正在努力弄清楚如何在 Laravel 配置文件中进行数据库查询。
我目前使用:
<?php
// config/database.php
$results = \Illuminate\Support\Facades\DB::select( \Illuminate\Support\Facades\DB::raw("select version()") );
$mysql_version = $results[0]->{'version()'};
dd($mysql_version);
return [
...
Run Code Online (Sandbox Code Playgroud)
但我收到的错误是:
RuntimeException in Facade.php line 218:
A facade root has not been set.
in Facade.php line 218
at Facade::__callStatic('raw', array('select version()')) in database.php line 2
at require('/Users/test/code/clooud/config/database.php') in LoadConfiguration.php line 70
at LoadConfiguration->loadConfigurationFiles(object(Application), object(Repository)) in LoadConfiguration.php line 39
at LoadConfiguration->bootstrap(object(Application)) in Application.php line 208
at Application->bootstrapWith(array('Illuminate\\Foundation\\Bootstrap\\LoadEnvironmentVariables', 'Illuminate\\Foundation\\Bootstrap\\LoadConfiguration', 'Illuminate\\Foundation\\Bootstrap\\HandleExceptions', 'Illuminate\\Foundation\\Bootstrap\\RegisterFacades', 'Illuminate\\Foundation\\Bootstrap\\RegisterProviders', 'Illuminate\\Foundation\\Bootstrap\\BootProviders')) in Kernel.php line 160
at Kernel->bootstrap() in Kernel.php line …Run Code Online (Sandbox Code Playgroud) 我努力this进入我的功能,如下所示:
console.log('geolocation is ' + this.isGeolocating);
let geocoder = new google.maps.Geocoder;
geocoder.geocode({'location': geolocation}, function(results, status, self = this) {
console.log('geolocation is ' + self.isGeolocating);
if (status === 'OK') {
if (results[0]) {
console.log(results[0]);
self.geolocated = 'success';
} else {
// No results found
self.geolocated = 'error';
}
} else {
console.log('Geocoder failed due to: ' + status);
self.geolocated = 'error';
}
});
this.isGeolocating = false;
Run Code Online (Sandbox Code Playgroud)
this在函数之前和之后可以正确访问,但是如何通过它?self在我的情况下也是未定义的.