She*_*din 2 inertiajs vuejs2 tailwind-css laravel-8 laravel-jetstream
我创建了一个带有 jetstream 和惯性 vue 堆栈的 laravel 应用程序,因为我的新项目问题是Tailwindcs版本 2 postCss,它不支持@applyvue 组件内部的指令,但在.css文件内部它工作正常我不想要那个,因为那个 css 文件将加载我的每个页面我只想要带有@apply指令的短内联实用程序类,但我不能,我该如何实现。?
<template>
<div class="mt-4">
<label for="hello">Hello</label>
<input id="hello" class="input"/>
</div>
</templete>
<style scoped>
.input {
@apply bg-gray-200 border h-10
}
</style>
Run Code Online (Sandbox Code Playgroud)
像这样在浏览器中输出
webpack.mix.js
const mix = require('laravel-mix');
mix.js('resources/js/app.js', 'public/js').vue()
.postCss('resources/css/app.css', 'public/css', [
require('postcss-import'),
require('tailwindcss'),
require('autoprefixer'),
])
.webpackConfig(require('./webpack.config'));
if (mix.inProduction()) {
mix.version();
}
Run Code Online (Sandbox Code Playgroud)
webpack.config.js
const path = require('path');
module.exports = {
resolve: {
alias: {
'@': path.resolve('resources/js'),
},
},
};
Run Code Online (Sandbox Code Playgroud)
tailwind version : "^2.0.1",
laravel version : 8.x,
jetstream version : 2.x,
inertiajs version: "^0.8.2"
Run Code Online (Sandbox Code Playgroud)
小智 5
你必须lang="postcss"在<style>标签上设置属性,因为 Tailwind 是一个 PostCSS 插件。
所以改变这个
<style scoped>
.input {
@apply bg-gray-200 border h-10
}
</style>
Run Code Online (Sandbox Code Playgroud)
对此
<style lang="postcss" scoped>
.input {
@apply bg-gray-200 border h-10
}
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1067 次 |
| 最近记录: |