我的DOM结构看起来像这样,当我使用D3.js渲染我的可视化并输入,更新,退出模式时:
g
rect
...
g
rect
...
g
rect
...
Run Code Online (Sandbox Code Playgroud)
我正在使用我的组中的多个元素和嵌套选择,但为了简单起见,我将使用rects演示这一点.DOM通过以下方式完成:
group = d3.select('.svg-content')
.selectAll('g')
.data(items, function (item) { return item.Id; });
groupEnter = group.enter()
.append('svg:g')
.attr('class','group-content');
// enter
groupEnter.append('svg:rect')
.style('fill', '#000')
.attr('x', function (item) { return item.x })
.attr('y', function (item) { return item.y; })
.attr('width', function (item) { return item.width; })
.attr('height', function (item) { return item.height; });
// update
group.select('rect')
.attr('x', function (item) { return item.x })
.attr('width', function (item) { return item.width; });
// remove
group.exit().remove(); …Run Code Online (Sandbox Code Playgroud) 我有一个需要Object.class参数的方法
method(Object.class)
Run Code Online (Sandbox Code Playgroud)
如何将类设置为此类的数组?就像是
method(ArrayList<Object>.class)
Run Code Online (Sandbox Code Playgroud)
我试过了
method(new ArrayList<Object>() {})
Run Code Online (Sandbox Code Playgroud)
同样.它不起作用.
我构建了我的应用程序wir create-react-app.在最近的版本中,它在Jest中的引导测试设置中添加了一行来卸载组件(请参阅参考资料ReactDOM.unmountComponentAtNode(div)).
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
Run Code Online (Sandbox Code Playgroud)
当我为我的App组件运行测试时,它会引发警告.
警告:只能更新已安装或安装的组件.这通常意味着您在已卸载的组件上调用了setState,replaceState或forceUpdate.这是一个无操作.
我猜:发生这种情况是因为我有一个异步请求componentDidMount():
fetchFoo(bar) {
fetch(SOME_URL)
.then(response => response.json())
.then(result => this.setState({ result }))
.catch(error => this.setState({ error }));
}
Run Code Online (Sandbox Code Playgroud)
如果是这种情况,我如何在测试中等待异步请求最终再次卸载组件?我知道我可以在Jest测试中移除一个衬里导致这个,但我想修复它.
目前,我的 GitHub Webhook 设置为每次主分支上发生推送时部署我的网站。现在,有了用于 CI 的 GitHub Actions,我只想在 GitHub 上的 CI 成功时运行此 Webhook。
我是否可以告诉我的 GitHub Webhook 等待 GitHub 的 CI ,或者我不应该再使用 Webhook,而是在 GitHub 工作流程中管理此行为?
我开始使用PostgreSQL,并且对创建数据库的两种方法感到困惑。第一次安装时,说明说我必须使用创建一个默认数据库。initdb /usr/local/var/postgres当我查找数据库时,可以看到我有一个名为postgres的数据库。现在,我可以使用其他两个命令创建数据库,而前一个是命令行脚本,而后者是SQL命令。对于名为“ postgres”的数据库,它将是:
createdb postgresCREATE DATABASE postgres两者都在我的数据库列表中建立了一个数据库。但是,当我尝试创建另一个数据库时initdb /usr/local/var/[someDbName],它没有出现在我的数据库列表中。那么,initdb和createdb有什么区别?
当我想从样式化组件迁移到 CSS 模块时,出现了以下问题。
假设我有以下样式组件,它接受动态参数offset和动态 CSS 字符串theme:
const Li = styled.li`
&.selected {
background-color: grey;
}
margin-left: ${({ offset }) => offset}px;
${({ theme }) => theme};
`;
Run Code Online (Sandbox Code Playgroud)
在我的代码中,我会按以下方式使用它:
const Parent = () => (
<List>
{list.map((item) => (
<Item
key={item.id}
id={item.id}
selectedIds={[]}
offset={24}
theme={`
&.selected {
background-color: green;
}
`}
>
{item.name}
</Item>
))}
</List>
);
const Item = ({ id, offset = 0, theme, children }) => {
return (
<Li
theme={theme}
offset={offset}
className={selectedIds.includes(id) && …Run Code Online (Sandbox Code Playgroud) Hybrid Cloud和Federated Cloud之间有什么区别吗?
我也读了很多"Intercloud"这个词.我将其理解为几个巨大的联合云的愿景,每个云都用于特殊目的.是对的吗?
当我调用
App.store.createRecord(App.User, { name: this.get("name") });
App.store.commit();
Run Code Online (Sandbox Code Playgroud)
我怎么知道它是否成功以及如何等待asyn消息?
主要思想:在我的控制器成功更新模型的属性后,我想调用一个关闭子视图的视图方法.
模板:
<a {{action showUpdate href=true target="view"}}>update</a>
{{#if view.isUpdate}}
{{#view App.UpdateView}}
...here is a form
<button {{action update}}>Send</button>
{{/view}}
{{/if}}
Run Code Online (Sandbox Code Playgroud)
视图:
App.MainView = Ember.View.extend({
templateName: 'update',
isUpdate: false,
showUpdate: function() {
this.set('isUpdate', !this.get('isUpdate'));
}
});
App.UpdateView= Ember.View.extend();
Run Code Online (Sandbox Code Playgroud)
控制器:
App.MainController = Ember.Controller.extend({
updateCon: function() {
do something
},
...
Run Code Online (Sandbox Code Playgroud)
路由器:
update: function(router, evt) {
router.get('mainController').updateCon();
//router.get('mainController.view').showUpdate(); <-- doesnt work
}
Run Code Online (Sandbox Code Playgroud)
所以我试着在我的控制器运行良好之后在我的路由器中调用它,但它不起作用.
Cannot call method 'showUpdate' of null
Run Code Online (Sandbox Code Playgroud)
这是正确的方法吗?什么时候:我错过了什么?当没有:当我的控制器做了什么时,如何改变我的观点?
对于我的登录/注销场景,我在ember中实现了条件路由:
App.Router = Ember.Router.extend({
//needs controller handling
//goLoggedIn: Ember.Route.transitionTo('loggedIn'),
goLoggedOut: Ember.Route.transitionTo('loggedOut'),
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
enter: function(router) {
var logged = getLoginState();
Ember.run.next(function() {
if (logged) {
router.transitionTo('loggedIn');
} else {
router.transitionTo('loggedOut');
}
});
}
}),
loggedIn: Ember.Route.extend({
connectOutlets: function(router, context){
...
}
}),
loggedOut: Ember.Route.extend({
connectOutlets: function(router, context){
...
}
})
...
Run Code Online (Sandbox Code Playgroud)
我的index.html对于登录视图说
<!-- Template for out -->
<script type="text/x-handlebars" data-template-name="out">
<hr /><br />
<h1>Logged Out</h1>
<span>Login with "test/test"</span><br /><br />
<label>Username: </label>{{view Ember.TextField valueBinding="App.OutController.username"}}<br />
<label>Password: …Run Code Online (Sandbox Code Playgroud) ember.js ×3
javascript ×2
reactjs ×2
ajax ×1
asynchronous ×1
cloud ×1
collections ×1
css ×1
css-modules ×1
d3.js ×1
ember-data ×1
git ×1
github ×1
github-api ×1
java ×1
postgresql ×1