小编El *_*bre的帖子

刀片中的 Vue 组件

我正在尝试在我的 Blade 视图中使用。我.vue在 JS 中有文件和以下代码:

import Multiselect from 'vue-multiselect'

export default {
  components: {
    Multiselect
  },
  data () {
    return {
      value: '',
      options: ['Select option', 'options', 'selected', 'mulitple', 'label', 'searchable', 'clearOnSelect', 'hideSelected', 'maxHeight', 'allowEmpty', 'showLabels', 'onChange', 'touched']
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

当我像这样在 Blade 中添加组件时:

<div>
   <label class="typo__label">Single select</label>
   <multiselect v-model="value" :options="options" :searchable="false" :close-on-select="false" :show-labels="false" placeholder="Pick a value"></multiselect>
   <pre class="language-json"><code>@{{value}}</code></pre>
</div>
Run Code Online (Sandbox Code Playgroud)

选择不起作用,它只显示{{value}}字符串。有任何想法吗?

laravel vue.js

2
推荐指数
1
解决办法
2万
查看次数

Flutter - 在底部导航栏中发送参数

我有两个不同的页面。其中一个是表单,另一个是元素列表。如果您向左滑动其中一个元素可以进行编辑。我需要将元素数据(从列表中)发送到第一页(表单)

当应用程序启动时,数据为空,如果它来自元素列表则不为空。

导航条码为:

import 'package:flutter/material.dart';
import 'package:datameter/screens/configuration/form/partials/home_page.dart';
import 'package:datameter/screens/configuration/list/datameters.dart';
import 'package:datameter/locations/locations.dart';

class Navigation extends StatefulWidget {

 final item;

  Navigation(
      {Key key,
      this.item})
      : super(key: key);

  @override
  State<StatefulWidget> createState() {
    return _NavigationState();
  }
}

class _NavigationState extends State<Navigation> {

  int currentIndex = 0;
  List<Widget> children = [
    HomePageScreen(datameter: widget.item), //ERRROR HERE
    DatametersPageScreen(),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: children[currentIndex],
      bottomNavigationBar: new Theme(
          data: Theme.of(context).copyWith(
            primaryColor: Colors.blue[700],
            textTheme: Theme.of(context)
                .textTheme
                .copyWith(caption: new TextStyle(color: Colors.black)),
          ),
          child: BottomNavigationBar(
            onTap: onTabTapped, …
Run Code Online (Sandbox Code Playgroud)

navigationbar flutter

2
推荐指数
1
解决办法
2039
查看次数

Flutter - LinearProgressIndicator 中的文本

在 Flutter 中,我有LinearProgressIndicator。有效,但我想在此栏内添加文本(进度)。

我尝试这样的事情

SafeArea(
  child: Row(children: <Widget>[
  Center(
    child: Text(DateFormat.ms()
                .format(DateTime.fromMillisecondsSinceEpoch(
                 minuteSecond * 1000))
                 .toString())),
           Expanded(
             child: LinearProgressIndicator(
                     semanticsLabel: (animation.value * 100.0).toStringAsFixed(1).toString(),                
                     semanticsValue:  (animation.value * 100.0).toStringAsFixed(1).toString(),   
                     value: animation.value,
                     backgroundColor: Colors.white,
                     valueColor:
                              AlwaysStoppedAnimation<Color>(Colors.red))),
])),
Run Code Online (Sandbox Code Playgroud)

但显然这将文本添加在栏的同一行中,而不是在里面。

所以:有人知道我如何在这个栏中添加中心(居中)?使用堆栈元素?

更新

有人知道如何在 ProgressBar 中垂直对齐文本吗?

不居中

flutter flutter-layout

2
推荐指数
1
解决办法
2257
查看次数

Flutter - 在 FutureBuilder 中等待 setState 然后加载组件

我\xc2\xb4m尝试类似的事情。在 Future Builder 中加载服务,设置文本字段值,然后编写组件。

\n\n
 final data = FutureBuilder(\n            future: DatameterService.getMapData(),\n            builder: (context, snapshot) {\n              if (snapshot.connectionState == ConnectionState.done) {\n                setState(() {\n                  calleController.text = snapshot.data.calle;\n                  paisController.text = snapshot.data.pais;\n                  provinciaController.text = snapshot.data.provincia;\n                  poblacionController.text = snapshot.data.poblacion;\n                  postalController.text = snapshot.data.postal;\n                });\n                return form;\n              } else {\n                return indicator;\n              }\n
Run Code Online (Sandbox Code Playgroud)\n\n

但返回

\n\n
\n

在构建期间调用 setState() 或 markNeedsBuild()。

\n
\n\n

所以问题是:如何使用 FutureBuilder 填充 TextField 输入值?

\n

flutter

0
推荐指数
1
解决办法
3797
查看次数

Flutter - 下拉值

我需要在颤振下拉列表中使用字符串作为值。但返回

抛出了另一个异常:'package:flutter/src/material/dropdown.dart': Failed assertion: line 609 pos 15: 'items == null || items.isEmpty || 值 == 空 || items.where((DropdownMenuItem item) => item.value == value).length == 1': 不是真的。

完整日志在这里

代码是

items: dataMaker.map((item) {
                          return new DropdownMenuItem<String>(
                            child: new Text(item['fabricante'],
                                textAlign: TextAlign.center),
                            value: item['fabricante'], //FAIL
                          );
                        }).toList(),
Run Code Online (Sandbox Code Playgroud)

所以我的问题是:如何使用字符串作为项目值?另一种解决方案是获取下拉文本,但我不知道如何。

- 解决方案 -

使用此代码,我可以找到 dataMaker 列表中与下拉菜单具有相同文本的所有元素。

 var test =dataMaker.firstWhere((fabricante) => fabricante["id"].toString() == dropdownSelectionMaker);              
 dataModelo = dataMaker.where((modelo) => modelo["fabricante"] == test["fabricante"]).toList();   
Run Code Online (Sandbox Code Playgroud)

dropdown flutter

-1
推荐指数
2
解决办法
6214
查看次数

Flutter - 在同一指令中创建列表和“addAll”

我正在尝试搜索数组中的一个元素。当得到它时,我需要在数组末尾附加一些元素。

我尝试与此类似。

List dataModelo = allMakers //THIS IS THE MAIN ARRRAY
                                    .where((modelo) =>
                                        modelo["fabricante"] ==
                                        fabricante["fabricante"])
                                    .toList()
                                    .addAll([
                                  {
                                    "id": 0,
                                    "fabricante":
                                        'Test,
                                    "modelo":
                                        'Test'
                                  }
                                ]);
Run Code Online (Sandbox Code Playgroud)

但是返回

此处的表达式具有“void”类型,因此不能使用。

所以有人知道我该怎么做?

解决方案

 dataModelo = allMakers
                                .where((modelo) =>
                                    modelo["fabricante"] ==
                                    fabricante["fabricante"])
                                .followedBy([
                              {
                                "id": 0,
                                "fabricante":
                                   'TEXT',
                                "modelo":
                                    'TEXT'
                              }
                            ]).toList();
Run Code Online (Sandbox Code Playgroud)

arrays arraylist flutter

-1
推荐指数
1
解决办法
2698
查看次数

JSON Filter return null

I´m trying to filter JSON array in Angular like this

JSON

1 46 3 2 48 4
Run Code Online (Sandbox Code Playgroud)

FILTER

   var test = this.users.filter(element => {
            element.id === 1;
          });
Run Code Online (Sandbox Code Playgroud)

The problem is 'test' variable return null in every cases. As we can see the 'id' 1 exist, so theoretically should return data. ¿Anybody know what is wrong in this code?

UPDATE

Full JSON response

  {id: 1, usuario: "alara", nombre: "alara", password: null, apellidos: "alara", …}
  {id: 46, usuario: "ale", nombre: "ale", …
Run Code Online (Sandbox Code Playgroud)

javascript arrays array-filter typescript

-1
推荐指数
1
解决办法
111
查看次数