You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel 5.6 + Vue.js 安装Now-UI-Kit遇阻,求技术指导

Troubleshooting Now-UI-Kit Installation in Laravel 5.6 + Vue.js

Hey there, let's work through getting Now-UI-Kit set up in your project. The key thing to note here is that unlike the regular UI Kit (which has a dedicated Laravel integration package), Now-UI-Kit doesn't come with an official Laravel wrapper—so we'll need to manually wire up its assets to your project. Here's a step-by-step guide:

1. Verify NPM Installation

First, confirm the package is properly installed in your node_modules directory. Run this command in your project root:

npm list now-ui-kit

If you see a path pointing to the package, you're good to move on. If not, re-install it with:

npm install now-ui-kit --save

2. Configure Laravel Mix

Laravel 5.6 uses Laravel Mix for asset compilation, so we'll add Now-UI-Kit's CSS and JS files to your webpack.mix.js file. Open it up and update it like this:

// Compile Now-UI-Kit CSS
mix.styles([
    'node_modules/now-ui-kit/css/now-ui-kit.css'
], 'public/css/now-ui-kit.css');

// Compile Now-UI-Kit JS (includes interactive components)
mix.scripts([
    'node_modules/now-ui-kit/js/now-ui-kit.js'
], 'public/js/now-ui-kit.js');

// Keep your existing Vue/Sass compilation as-is
mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css');

Note: Now-UI-Kit often depends on jQuery and Popper.js. If you don't have these installed yet, run:

npm install jquery popper.js --save

3. Load Assets in Your Blade Layout

Next, you need to include the compiled Now-UI-Kit assets in your main Blade template (usually resources/views/layouts/app.blade.php). Add these lines before your app's own CSS/JS to ensure styles don't get overridden:

<!-- Now-UI-Kit Styles -->
<link rel="stylesheet" href="{{ asset('css/now-ui-kit.css') }}">

<!-- Your App's Styles -->
<link rel="stylesheet" href="{{ asset('css/app.css') }}">

<!-- ... rest of your HTML content ... -->

<!-- Now-UI-Kit Scripts -->
<script src="{{ asset('js/now-ui-kit.js') }}"></script>

<!-- Your App's Scripts -->
<script src="{{ asset('js/app.js') }}"></script>

4. Integrate Vue Components (If Needed)

If you want to use Now-UI-Kit's Vue-specific components, register them globally in resources/js/app.js:

import Vue from 'vue';
// Import individual components or the full kit
import { NowButton, NowCard } from 'now-ui-kit';

// Register components for global use
Vue.component('now-button', NowButton);
Vue.component('now-card', NowCard);

// Alternatively, register the entire kit (if supported)
// import NowUIKit from 'now-ui-kit';
// Vue.use(NowUIKit);

const app = new Vue({
    el: '#app'
});

You can then use these components directly in your Vue files, like <now-button>Click Me</now-button>.

5. Compile and Test

Finally, compile all your assets with:

npm run dev

For production, use npm run prod instead. Refresh your browser, and you should see Now-UI-Kit's styles and components working in your project.

Common Pitfalls to Check

  • Incorrect File Paths: Double-check the path to Now-UI-Kit's files in node_modules—some versions might store assets in a dist subfolder (e.g., node_modules/now-ui-kit/dist/css/now-ui-kit.css).
  • Style Conflicts: If your existing UI Kit styles are clashing, try removing the old UI Kit's assets from your mix file and layout template.

内容的提问来源于stack exchange,提问作者user9465677

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:23:31