显示一定数量的文字字符

时间:2017-02-11 08:02:28

标签: javascript text

我想缩小文字,以便只显示30个字符 喜欢 var data = [{ a : "aa", b : "bb" } ]; for(var i in data){ console.log(Object.keys(data[i])); // Get keys of objects console.log(data[i]); // Print the object console.log(data[i].a) // Print value one by one } 我想成为一个文本<p>Piqued favour stairs it enable exeter as seeing</p>

使用javascript

(&#34;显示一定数量的文字字符&#34;)

2 个答案:

答案 0 :(得分:1)

这可能是我使用vanilla JS提供的最简单的答案。它应该适合你。如果没有,请告诉我。

&#13;
&#13;
const trimSize = 20;
let text = '<p>Something that is too big and you want to trim, and then renddeer in your HTML page.</p>';

let content = text.substring(3, text.length - 4);

let trimmedText = '<p>' + content.substring(0, trimSize) + '<\p>';
console.log(trimmedText);
&#13;
&#13;
&#13;

答案 1 :(得分:0)

这可能是您问题的答案:

&#13;
&#13;
if ($request->hasFile('image')) {
   $image = $request->file('image');
   $filename = time() . '.' . $image->getClientOriginalExtension();
   $location = public_path('images/comment/' . $filename);
   Image::make($image)->resize(800, 600)->save($location);
}
&#13;
&#13;
&#13;

相关问题