鍍金池/ 問答/HTML/ vue的js html和css可以分開寫嗎

vue的js html和css可以分開寫嗎

代碼太多了,應該怎么分開引入,小白求解
clipboard.png

回答
編輯回答
尛憇藌

<template>
<div>This will be pre-compiled</div>
</template>
<script src="./my-component.js"></script>
<style src="./my-component.css"></style>

2017年3月9日 18:17
編輯回答
深記你
2018年7月19日 17:03
編輯回答
影魅

專門有個style文件夾放css文件,在你的vue文件import不就好了

2017年1月2日 00:02
編輯回答
互擼娃

可以,通過src引入就可以了,官方文檔就有說,仔細讀一下。

2018年2月18日 22:05
編輯回答
澐染

安裝vgc

2018年3月4日 12:01
編輯回答
爛人

樓上各位回答了。
但我覺得不應該有。

代碼太多應該把各個功能獨立開來,不然為什么要模塊化?

2017年7月22日 07:09
編輯回答
安淺陌
//index.vue
<script> 
import template from './index.html'

export default {
  template
}
</script>

<style  scoped> 
@import './index.css';
</style>
//index.html
<input type="text" class="input">
//index.css
.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid blue;
}
2018年1月23日 15:41