前提
vueを用い,HTML,Java Script,cssのみで動的なグラフを作成したいです.
実現したいこと
HTMLのstyle="width: ○○%”の部分にjava scriptの変数を使いたいです.
dataが使いたい変数です.
該当のソースコード
html
1<div class="graph"> 2 <span class="bar" style="width: ○○%;">{{ data }}%</span> 3</div>
css
1.graph { 2 position: relative; /* IE is dumb */ 3 width: 300px; 4 border: 1px solid #207870; 5 padding: 2px; 6} 7.graph .bar { 8 display: block; 9 position: relative; 10 background: #409890; 11 text-align: center; 12 color: #f0ffff; 13 height: 2em; 14 line-height: 2em; 15} 16.graph .bar span { position: absolute; left: 1em; }