LoginSignup
0
0

More than 3 years have passed since last update.

vue.jsで画像を表示(v-bind使用)

Last updated at Posted at 2021-02-20

ディレクトリ

app
 ├ assets
 |   L images
 |       L image1.jpg
 └ javascripts
        L components
             L TopImage.vue ←ここからimage1.jpg表示したい

今回はv-bindを使用。

#TopImage.vue

<template>
  <div id="app">
    <img :src="topImage">
  </div>
</template>

<script>
export default {
  el: 'app',
  data: function () {
    return {
      topImage: require('../../assets/images/image1.jpg')
    }
  }
}
</script>

*requireを使うことで表示できた
*ディレクトリの構造がややこしいので注意

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