How to limit the scope of introducing css files into vue js module

problem description

how to limit the scope of introducing css files into the vue js module

the environmental background of the problems and what methods you have tried

Project components are generally divided into three files: html template and css,js. Js is introduced into the first two respectively. The styles set by tag selector in the common style file vender generated by webpack compilation will be confused

how to solve this problem?

A picture is attached, which is the common style compiled by css in a page developer"s tool

clipboard.png

directory structure:
_

|_index.js
|_style.css
|_tmpl.html

index.js file:

let style = require("./style.css")
if(style.locals) style = style.locals

export default {
    template,
    data() {
        return {
            style
        }
    },
}

suggest a page an id all styles are written under this id recommended less/sass this advantage is that you can modify the style of third-party components.
scoped is also OK, but when modifying third-party components, some can not be modified, so you can only define a style, to modify it, which is very troublesome.


scoped find out: ide/scoped-css.html" rel=" nofollow noreferrer > https://vue-loader.vuejs.org/.


on the same floor, scoped


on the same floor, scoped


use import ('cssPath') to write conditional statements in mounted of vue components.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3723e-2c073.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3723e-2c073.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?