我正在使用Extjs进行测试,并且被困在另一个组件中使用组件。这是我所拥有的:
这是主要组成部分:
add_filter( 'woocommerce_quantity_input_args', 'quantity_input_args_filter_callback', 10, 2 );
function quantity_input_args_filter_callback( $args, $product ) {
// HERE define the user role:
$user_role = 'customer_roles';
$user = wp_get_current_user(); // Get the WP_Use Object
// For a specific user role, we keep default woocommerce quantity settings
if( in_array( $user_role, $user->roles ) )
return $args; // Exit to default
// For the others as following
if ( is_singular( 'product' ) ) {
if( $product->get_id() == 85 ) {
$args['input_value'] = 30;
} else {
$args['input_value'] = 5;
}
}
if( $product->get_id() == 85 ) {
$args['min_value'] = 30;
$args['step'] = 5;
} else {
$args['min_value'] = 5;
$args['step'] = 5;
}
return $args;
}
这是我要渲染的组件:
var component = Ext.create('mypackages.mycomponent');
Ext.define('mypackages.maincomp', {
extend: 'Ext.window.Window',
itemId: 'maincomp',
xtype: 'maincomp',
modal: true,
bodyPadding: 10,
height: 350,
width: 270,
closeAction: 'destroy',
resizable: false,
renderTo: Ext.getBody(),
layout: {
type: 'table',
columns: 1
},
items: [
{
xtype: 'textfield',
fieldLabel: 'Name',
name: 'name',
labelAlign: 'right',
width: 265,
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Age',
name: 'age',
labelAlign: 'right',
width: 265,
allowBlank: false
},
{
xtype: 'textfield',
fieldLabel: 'Phone',
name: 'phone',
labelAlign: 'right',
width: 265,
allowBlank: false
},
{
item: component
}
]
});
如您所见,我正在尝试加载Ext.define('mypackages.component', {
extend: 'Ext.Component',
id: 'component',
alias: 'component',
items: [
{
xtype: 'textfield',
fieldLabel: 'Address',
name: 'address',
id: 'address',
labelAlign : 'right',
width: 265,
allowBlank: false
}
],
constructor: function () {
this.callParent();
console.log('I am entering here!!!');
}
});
这样的组件,由于浏览器的控制台向我显示了item: component
消息,因此它实际上正在调用该组件。问题是“电话”文本字段后未显示该组件。我在这里想念什么?是否有必要强制显示组件?如果是这样,我该如何实现?
答案 0 :(得分:1)
您要声明自己的字段类型:
try:
num1 = float(input('Enter the first number: '))
except ValueError:
print('Invalid number')
num1 = float(input('Enter first number again: '))
op = input('Enter operator: ')
try:
num2 = float(input('Enter the second number: '))
except ValueError:
print('Invalid number')
num2 = float(input('Enter second number again: '))
def ops():
if op != '+' or '-' or '/' or '*':
op = input('Invalid Operator, please enter operator: ')
elif op == '+':
return num1 + num2
elif op == '-':
return num1 - num2
elif op == '*':
return num1 * num2
elif op == '/':
return num1 / num2
print(ops)
答案 1 :(得分:0)
在主要组件中:
首先:删除第一行。您无需在此处创建新实例。
var component = Ext.create('mypackages.mycomponent');
下一个更改无效行:
{
item: component
}
收件人:
{
xtype: 'newComponent'
}
最后在第二个部分中设置别名:
alias: 'widget.newComponent',