cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div class="box" id="Vue">
	<div class="clerafix mb10">
		<input type="text" v-model="todo" class="w300 inpTxt01" v-on="keydown : onKeydown">
		<button class="inpBtn01" v-on="click : push">追加</button>
		<button class="inpBtn02" v-on="click : clear">全て削除</button>
	</div>
	<ul class="lastItem todoList">
		<li v-repeat="list">
			{{$index + 1}}.<span class="ml10">{{todo}}</span>
			<a class="disRight" href="javascript:void(0)" v-on="click : slice($index)">削除</a>
		</li>
	</ul>
</div>
            
          
!
            
              @charset "UTF-8";


/* ------------------------------------------------------------
init
------------------------------------------------------------ */

html {
	margin: 0;
	padding: 0;
	font-size: 62.5%;
}

body {
	margin: 0;
	padding: 0;
	font-weight: normal;
	font-style: normal;
	font-size: 1.3rem;
	font-size: 13px;
	font-family: sans-serif;
	line-height: 1.5;
	font-family: 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', 'メイリオ', Meiryo, Osaka, 'MS Pゴシック', 'MS PGothic', Verdana, Arial, Helvetica, sans-serif;
	-webkit-text-size-adjust: none;
	-moz-text-size-adjust: none;
	-ms-text-size-adjust: none;
}

em, strong {
    font-style: normal;
    font-weight: bold;
}

ul {
	margin: 0;
	padding: 0;
}

li {
	list-style: none;
}

/* ------------------------------------------------------------
clearfix
------------------------------------------------------------ */
.clearfix:after {
	display: block;
	visibility: hidden;
	clear: both;
	height: 0;
	content: ".";
}

/* ------------------------------------------------------------
Parts
------------------------------------------------------------ */

.box{
	border-radius: 3px;
	padding: 10px;
	width: 800px;
}

ul.todoList{
	border-radius: 3px;
	overflow: auto;
}

ul.todoList li{
	border-bottom: 1px dotted #cccccc;
	padding: 10px;
	position: relative;
	cursor: pointer;
	font-size: 120%;
}

ul.todoList li .disRight{
	position: absolute;
	text-decoration: none;
	right: 10px;
}

ul.todoList li:last-child{
	border-bottom: none;
}

.inpBtn01{
	padding: 8px 20px;
	background: #337ab7;
	border: 1px solid #337ab7;
	border-radius: 3px;
	color: #ffffff;
	cursor: pointer;
}

.inpBtn02{
	padding: 8px 20px;
	background: #d9534f;
	border: 1px solid #d9534f;
	border-radius: 3px;
	color: #ffffff;
	cursor: pointer;
}


.inpTxt01{
	border: 1px solid #cccccc;
	-webkit-box-sizing: border-box;
	-moz-box-sizing: border-box;
	box-sizing: border-box;
	font-size:  138.5%;
	padding: 5px;
	border-radius: 3px;
	vertical-align: middle;
}

.inpTxt01:focus{
	background: #CDE7F1;
}

.ml10{
	margin-left: 10px;
}

.mb10{
	margin-bottom: 10px;
}
            
          
!
            
              var JsonData = []; // グローバル変数を宣言

if(window.localStorage){// localStorageが使用できるかチェック
	if(window.localStorage.getItem("JsonData")){// JsonDataがキーとしてあるかチェック
		var json = window.localStorage.getItem("JsonData");// JsonDataを取り出し
		JsonData = JSON.parse(json); // 文字列をオブジェクトに変換
	}
}

// localStorageに、キー名とオブジェクトをセット
function setLocalStorage(setKey , jsonData){
	var json = JSON.stringify(jsonData); //オブジェクトを文字列に変換
	window.localStorage.setItem(setKey , json);// オブジェクトをlocalStorageに保存
}

  // Vue インスタンスの生成
	var vm = new Vue({
		el: '#Vue', //データバインディングの対象となる、DOM要素を指定
		data: { //モデルとなるオブジェクトを指定
			'list': JsonData, //localStorageに保存された、JsonDataをセット
			'todo' : '' //空のオブジェクトをセット
		} ,
		methods: {
			'push' : function(){
				this.list.push({'todo': this.todo}); // todoオブジェクトをlistに追加
				this.todo = ''; // todoオブジェクトを空にする
				setLocalStorage('JsonData' , this.list); // オブジェクトをlocalStorageに保存
			},
			'slice' : function(index){
				this.list.splice(index , 1); // 指定されたインデックスの要素を削除
				setLocalStorage('JsonData' , this.list); // オブジェクトをlocalStorageに保存
			} ,
			'onKeydown' : function(e){
				if(e.keyCode === 13){ // Enterキーが押されると、pushメソッドが実行
					this.push();
				}
			} ,
			'clear' : function(){
				this.list = []; //list要素を全て空に
        setLocalStorage('JsonData' , this.list); // オブジェクトをlocalStorageに保存
			}
		}
	});
            
          
!
999px
Loading ..................

Console