React & styled component
React & styled component
https://www.styled-components.com/#your-first-styled-component
tagged template literals
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#Tagged_templates
https://www.styled-components.com/docs/advanced#tagged-template-literals
let person = 'Mike';
let age = 28;
const myTag = (strings, personExp, ageExp) => {
let str0 = strings[0]; // "That "
let str1 = strings[1]; // " is a "
// There is technically a string after
// the final expression (in our example),
// but it is empty (""), so disregard.
// var str2 = strings[2];
let ageStr;
if (ageExp > 99) {
ageStr = 'centenarian';
} else {
ageStr = 'youngster';
}
// We can even return a string built using a template literal
return `${str0}${personExp}${str1}${ageStr}`;
}
let output = myTag`That ${person} is a ${age}`;
console.log(output);
// That Mike is a youngster
React & styled component的更多相关文章
- react slot component with args
react slot component with args how to pass args to react props child component https://codesandbox.i ...
- react hooks & component will unmount & useEffect & clear up
react hooks & component will unmount & useEffect & clear up useEffect & return === u ...
- [React] Create component variations in React with styled-components and "extend"
In this lesson, we extend the styles of a base button component to create multiple variations of but ...
- [React Fundamentals] Component Lifecycle - Updating
The React component lifecycle will allow you to update your components at runtime. This lesson will ...
- [React Fundamentals] Component Lifecycle - Mounting Usage
The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson ...
- [React Fundamentals] Component Lifecycle - Mounting Basics
React components have a lifecycle, and you are able to access specific phases of that lifecycle. Thi ...
- [React] React Fundamentals: Component Lifecycle - Updating
The React component lifecycle will allow you to update your components at runtime. This lesson will ...
- [React ] React Fundamentals: Component Lifecycle - Mounting Usage
The previous lesson introduced the React component lifecycle mounting and unmounting. In this lesson ...
- [React] React Fundamentals: Component Lifecycle - Mounting Basics
React components have a lifecycle, and you are able to access specific phases of that lifecycle. Thi ...
随机推荐
- vector基础操作
//vector< T> vec; //构造一个名为vec的储存数据类型为T的动态数组.其中T为需要储存的数据类型 //初始时vec为空 //push_back 末尾添加一个元素 //po ...
- ABAP术语-APO (Advanced Planner and Optimizer)
APO (Advanced Planner and Optimizer) 原文:http://www.cnblogs.com/qiangsheng/archive/2007/12/14/994510. ...
- js面试之一个字符串中出现次数最多的字符是?出现几次?
最近在找面试题的时候发现了许多有趣的题目,在这里用随笔记录下~ 关于“一个字符串中出现次数最多的字符...”这种问题在笔试题中出现的频率还是很高的,我自己也找到了几种方法处理 var str = &q ...
- C# Regex正则验证规则
using System; using System.Text.RegularExpressions; namespace MetarCommonSupport { /// <summary&g ...
- hdcms v5.7.0学习笔记
hdcms v5.7.0学习笔记 https://note.youdao.com/ynoteshare1/index.html?id=c404d63ac910eb15a440452f73d6a6db& ...
- JavaSE基础复习---Class类与反射机制
---恢复内容开始--- 目录: 1.java.lang.class类 2.Java中的反射机制 3.运行时与编译时概念 1. java.lang.class类 Java程序在运行时,Java运行时系 ...
- linux-课题练习1
1.创建组testgroup: 2.创建用户a2012,先采用默认设置创建,然后使该用户加入testgroup组. 3.创建用户a2013,其用户主目录为/tmp/a2013,其主组为testgrou ...
- linux挂载命令mount及U盘、移动硬盘的挂载
一.mount的命令格式是(注意mount只能在root权限下运行) mount dervice dir dervice是要挂载的设备,dir是挂载点 二.查看当前磁盘列表的设备 fdisk -l 显 ...
- poj1050 dp动态规划
Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any ...
- mongodb 安装使用遇到的问题记录
mongodb 常用命令: https://www.mongodb.org/downloads 官网64位下载链接 https://fastdl.mongodb.org/linux/mongodb-l ...