我们的聊天机器人的一些答案很长。网络聊天会自动滚动到底部,因此用户必须向上滚动才能到达气泡顶部并开始阅读。
我已经实现了一个自定义渲染器 (react) 来将答案包装到一个自定义组件中,该组件只是将答案包装到一个 div 标签中。我还实现了一段简单的代码来滚动到气泡的顶部。
const MyCustomActivityContainer = ({ children }) => {
const triggerScrollTo = () => {
if (scrollRef && scrollRef.current) {
(scrollRef.current as any).scrollIntoView({
behavior: 'smooth',
block: 'start',
})
}
}
const scrollRef: React.RefObject<HTMLDivElement> = React.createRef()
return (
<div ref={ scrollRef } onClick={ triggerScrollTo }>
{ children }
</div>
)
}
export const activityMiddleware = () => next => card => {
if (/* some conditions */) {
return (
<MyCustomActivityContainer>
{ next(card) }
</MyCustomActivityContainer>
); …Run Code Online (Sandbox Code Playgroud) 我有一张看起来像这样的表:
id timestamp value1 value2
1 09:12:37 1 1
1 09:12:42 1 2
1 09:12:41 1 3
1 10:52:16 2 4
1 10:52:18 2 5
2 09:33:12 3 1
2 09:33:15 3 2
2 09:33:13 3 3
Run Code Online (Sandbox Code Playgroud)
我需要按 id 和 value1 分组。对于每个组,我想要具有最高时间戳的行。
上表的结果如下所示:
id timestamp value1 value2
1 09:12:42 1 2
2 09:33:15 3 2
Run Code Online (Sandbox Code Playgroud)
我知道有一个汇总运算符会给我这个:
mytable
| project id, timestamp, value1, value2
| summarize max(timestamp) by id, value1
Result:
id timestamp value1
1 09:12:42 1
2 09:33:15 3
Run Code Online (Sandbox Code Playgroud)
但是我也无法获得此行的 …
我在我的reactjs应用程序中使用react-portal。我创建了两个根元素,一个用于渲染 React 应用程序,另一个用于 React-portal:
<html>
<head></head>
<body>
<div id='react-root-element' />
<div id='react-portal-root-element' />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
我还有一个组件 MyComponent,它使用react-portal 将内容渲染到react-portal-root-element。内容由具有 id 的 div 元素(我们称其为“container-div”)包装。
我的组件:
export class MyComponent extends React.Component {
// constructor ...
render() {
return (
<Portal node={ 'react-portal-root-element' }>
<div id='divTest_id'>
// some more content
</div>
</Portal>
);
}
}
Run Code Online (Sandbox Code Playgroud)
MyComponent 的父级:
export class MyComponentParent extends React.Component {
// ...
someMethod => {
this.setState({ myProp: someNewValue });
}
render() {
return (
<div>
<MyComponent someProp={ this.state.myProp } />
</div> …Run Code Online (Sandbox Code Playgroud) 我喜欢用Matlab或Octave可视化圆锥曲线.对于点p =(x,y,z),(一般)圆锥曲线由等式0 = a x 2 + b x y + c y 2 + d x z + e y z + f*z 2给出.如果我知道参数a,b,c,d,e和f,我怎么能用Matlab或八度音来绘制?或者,我怎样才能找到满足这个等式的点?
reactjs ×2
botframework ×1
javascript ×1
matlab ×1
octave ×1
plot ×1
react-portal ×1
web-chat ×1