LoginSignup
0
0

More than 3 years have passed since last update.

vue.js truncate

Posted at

以下を参考にしたが、引数を取得できなくて
うまく動かない。

ということで最新版。

app.js

Vue.filter('truncate', (value, length) => {
    if(value){
        var length = length ? parseInt(length, 10) : 20;
        if (value.length <= length) {
            return value;
        }
        return value.substring(0, length) + '...';
    }
});

hoge.vue

<p>{{v.make_body_text | truncate(180) }}</p>


これで 180文字に省略されて出力される。

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