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 Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

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
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console