0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vuejs画面表示時にマスタッシュ{{}}が見える

Posted at

Vuejs画面表示時にマスタッシュ{{}}が表示されるのを解消する

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <title>test</title>
  <style>
    [v-cloak] { opacity: 0; }
  </style>
</head>

<body>
  <div id="app" v-clock>
    <h1>{{ hoge }}</h1>
  </div>

<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

<script>
new Vue({
  el: '#app',
  data: {
    hoge: 'テスト',
  }
})
</script> 
</body>
</html>

原因

vueがコンポーネントのインスタンスを初期化する前にブラウザがhtmlを表示するから

v-clock

v-clockはコンポーネントのインスタンス初期化・データバインディングが完了するとDOMから消える。
なのでその間cssで非表示にすることでユーザーから状態を隠すことができる。

clockの意味はマントとか覆い隠すものという意味だそうです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?