6.1 style scoped

2019. 7. 17. 17:37Front-End/Vue

이번시간에는 style scoped에 대해 확인해 보겠습니다. 

 

<style> 태그가 scoped 속성을 가지고있을 때, css는 현재 컴포넌트의 엘리먼트에만 적용됩니다. 

자세한 설명은 아래 url 을 확인부탁드립니다. 

 

https://vue-loader-v14.vuejs.org/kr/features/scoped-css.html

 

범위 CSS · vue-loader

범위를 가지는 CSS 태그가 scoped 속성을 가지고있을 때, CSS는 현재 컴포넌트의 엘리먼트에만 적용됩니다. 이는 Shadow DOM에 있는 스타일 캡슐화와 유사합니다. 여기에는 몇 가지 주의사항이 있지만 폴리필은 필요 없습니다. PostCSS를 사용한다면 다음과 같이 변환할 수 있습니다. .example { color: red; } 안녕 다음과 같이 변환됩니다. .example[data-v-f3f3eg9] { color: red; } 안녕 참고사항

vue-loader-v14.vuejs.org

 

common.css 파일을 삭제 후 각각의 .vue 파일에 style을 적용합니다. 

 

위 내용을 확인해보면 data-v-...... 이라는 속성이 추가됩니다. 하지만 모든 태그에 동일하게 적용되지는 않고 있습니다. 

<style scope> 내의 css가 정상적으로 적용이 안되는 문제가 발생합니다. 

 

>>> Deep selectors 를 적용해서 문제를 해결했습니다. 

 

https://vue-loader.vuejs.org/guide/scoped-css.html#deep-selectors

 

Scoped CSS | Vue Loader

Scoped CSS When a tag has the scoped attribute, its CSS will apply to elements of the current component only. This is similar to the style encapsulation found in Shadow DOM. It comes with some caveats, but doesn't require any polyfills. It is achieved by u

vue-loader.vuejs.org

 

 

 

 

 

*** 공통 ***

작업완료시 푸시/커밋/빌드/firebase배포/앱적용

1. 커밋 후 푸시

 

https://github.com/imse0109/noteApp/commit/d13a272f167948743d84aa36277ef60537c1a82f

 

6.1 style scoped · imse0109/noteApp@d13a272

Permalink Browse files 6.1 style scoped Loading branch information... Showing 5 changed files with 22 additions and 29 deletions. +0 −24 src/assets/css/common.css +7 −1 src/components/List.vue +9 −2 src/components/View.vue +6 −1 src/components/Write.vue +0

github.com

2. 빌드

터미널 appnote > npm run build

 

***** config/index.js *****

master 브랜치

1. firebase 배포시 - 상대경로

2. 앱 배포시 - 절대경로

 

 

3, firebase 배포

터미널 appnote > firebase deploy

 

4. 앱적용

4-1. dist 폴더 내에 static/index.html 복사

4-2. 브랜치 ionic 으로 변경

4-3. www 폴더 내로 static/index.html 붙여넣기

(붙여넣기 후  ionic-app-note/www/static/css/app.css 파일내의 font 경로 수정 ../../ -> MaterialIcons 처리)

 

4-4. 터미널 ionic-app-note > cordova build

4-5. app-debug.apk 파일생성 후 폰테스트

 

 

***** 앱제작가이드 *****

1. npm i cordova -g

www.npmjs.com/package/cordova?activeTab=dependents

2. Android Studio 설치

3. Gradle 설치/환경변수 설정

gradle.org/install/

4. Android SDK 설치

developer.android.com/studio/intro/update.html#download-with-gradle

 

'Front-End > Vue' 카테고리의 다른 글

5. 프론트 화면 설계  (0) 2019.06.17
4. Ionic App 환경설정  (0) 2019.06.12
3. Firebase 연결 및 배포  (0) 2019.06.10
2. vuetify 설치  (0) 2019.06.05
1. vue-cli 설치  (0) 2019.03.05