<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>elementui</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
</head>
<body>
<div id="app">
<el-tag :color="setColor('success')">标签一</el-tag>
<el-tag :color="setColor('error')">标签二</el-tag>
<el-tag :color="setColor('warning')">标签三</el-tag>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
},
methods: {
setColor (typ) {
switch(typ) {
case 'success':
return '#FFB6C1';
case 'warning':
return '#228B22';
case 'error':
return '#191970';
default:
return '#00CED1'
}
}
}
})
</script>
</body>
</html>
效果图: 同理 在标签的其他属性上也可以这么来获取值
|