[Next.js] Serve Optimized Images Using the Next.js Image Component
JS The Using Image Component Next Images Serve
2023-09-14 09:00:45 时间
The image component from Next.js comes with excellent performance optimizations that make it worth using. It comes with improved performance, better visual stability, faster page loads, and more!
In this lesson you’ll learn how to use this component to serve both local and remote images in your Next.js app.
import Image from "next/image";
// You don't need to put image into `public` directory but reocmmended
// you can put images anywhere you like
// import dog.png statically
import dog from '../dog.png';
// You can load image from remote server
// but you need to config domain in next.config.js
const TWITTER_IMG_URL = "https://pbs.twing.com/profile_iamges/xxxxxxx_400x400.jpg";
const Home = () => {
return (
<>
<Image src={dog} lat="cute dog" />
<Image src={TWITTER_IMG_URL} lat="Leader" alt="profile image" width={550} height={650} />
</>
)
}
next.config.js
module.exports = {
images: {
domains: ['pbs.twimg.com']
}
}
相关文章
- js面试题及答案2020_JS面试题大全
- JS 中 scrollWidth、scrollHeight、scrollLeft 、scrollTop 详解
- 【说站】js中arguments的使用
- JS防抖与节流
- 【踩坑实录】-java.sql.SQLException: The MySQL server is running with the LOCK_WRITE_GROWTH option so it ca
- JS知识点梳理--作用域、作用域链、柯里化、闭包
- 【JS 逆向百例】猿人学系列 web 比赛第五题:js 混淆 - 乱码增强,详细剖析
- 原生 JS 实现 HTML 转 Markdown ,html2md.js
- 如何使用jscythe并通过Node.js的Inspector机制执行任意JS代码
- 【Vue-Spring跨域Bug已解决】has been blocked by CORS policy: The value of the······
- js 修改文本框的值
- ORA-38407: The ADT associated with the attribute set already exists. ORACLE 报错 故障修复 远程处理
- ORA-48490: The field number exceeds the maximum number [string] ORACLE 报错 故障修复 远程处理
- js获取当前系统时间详解编程语言
- js cookie操作详解编程语言
- 第一个JS实例
- Exploring the Magic of Linux and Node.js(linuxinode)
- The Power of the Hydra Oracle: Unlocking Potential(hydraoracle)
- Exploring the Depths of Linux: The Power of the l Command(linux-l)
- Exploring the Power of Linux and Node.js for Web Development: A Comprehensive Guide(linuxnodejs)
- Exploring the Power of Linux: The Versatility and Potential of Aud Files(linux系统aud文件)
- Discover the Power of Linux with YLMF: The UserFriendly Operating System(linuxylmf)
- Exploring the Power of as86 Linux: The Ultimate Guide for Beginners!(as86linux)
- js实现的的文字自动'到googlesearch框
- 后缀就扩展名为js的文件是什么文件原创
- JS图片缩放效果代码
- JS键盘的键码(event.keyCode)图片版
- JS分页控件可用于无刷新分页
- Chrome扩展页面动态绑定JS事件提示错误
- node.js正则表达式获取网页中所有链接的代码实例
- JS使用for循环遍历Table的所有单元格内容