小编tex*_*697的帖子

发布来自React Native的x-www-form-urlencoded请求

我有一些参数,我想将表格编码POST到我的服务器:

{
    'userName': 'test@gmail.com',
    'password': 'Password!',
    'grant_type': 'password'
}
Run Code Online (Sandbox Code Playgroud)

我正在发送我的请求(目前没有参数)

var obj = {
  method: 'POST',
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  },
};
fetch('https://example.com/login', obj)
  .then(function(res) {
    // Do stuff with result
  }); 
Run Code Online (Sandbox Code Playgroud)

如何在请求中包含表单编码的参数?

javascript http-post react-native fetch-api

62
推荐指数
9
解决办法
7万
查看次数

如何为multipart/form-data设置webapi控制器

我想弄清楚如何完成这件事.我没有使用我的代码获得任何有用的错误消息,所以我使用其他东西来生成一些东西.我在错误消息后附加了该代码.我已经找到了一个教程,但我不知道如何用我所拥有的实现它.这就是我现在拥有的

public async Task<object> PostFile()
    {
        if (!Request.Content.IsMimeMultipartContent())
            throw new Exception();


        var provider = new MultipartMemoryStreamProvider();
        var result = new { file = new List<object>() };
        var item = new File();

        item.CompanyName = HttpContext.Current.Request.Form["companyName"];
        item.FileDate = HttpContext.Current.Request.Form["fileDate"];
        item.FileLocation = HttpContext.Current.Request.Form["fileLocation"];
        item.FilePlant = HttpContext.Current.Request.Form["filePlant"];
        item.FileTerm = HttpContext.Current.Request.Form["fileTerm"];
        item.FileType = HttpContext.Current.Request.Form["fileType"];

        var manager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(new ApplicationDbContext()));
        var user = manager.FindById(User.Identity.GetUserId());

        item.FileUploadedBy = user.Name;
        item.FileUploadDate = DateTime.Now;

        await Request.Content.ReadAsMultipartAsync(provider)
         .ContinueWith(async (a) =>
         {
             foreach (var file in provider.Contents)
             { …
Run Code Online (Sandbox Code Playgroud)

c# multipartform-data asp.net-web-api

47
推荐指数
5
解决办法
9万
查看次数

如何下载zip文件

我想从我的web api控制器下载一个zip文件.它正在返回文件但我收到一条消息,当我尝试打开时,zipfile无效.我已经看过其他关于此的帖子,响应是添加了responseType:'arraybuffer'.仍然不适合我.我也没有在控制台中出现任何错误.

  var model = $scope.selection;
    var res = $http.post('/api/apiZipPipeLine/', model)

    res.success(function (response, status, headers, config) {
        saveAs(new Blob([response], { type: "application/octet-stream", responseType: 'arraybuffer' }), 'reports.zip');
            notificationFactory.success();
    });
Run Code Online (Sandbox Code Playgroud)

api控制器

 [HttpPost]
    [ActionName("ZipFileAction")]
    public HttpResponseMessage ZipFiles([FromBody]int[] id)
    {
        if (id == null)
        {//Required IDs were not provided
            throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.BadRequest));
        }

        List<Document> documents = new List<Document>();
        using (var context = new ApplicationDbContext())
        {
            foreach (int NextDocument in id)
            {
                Document document = context.Documents.Find(NextDocument);

                if (document == null)
                {
                    throw new HttpResponseException(new …
Run Code Online (Sandbox Code Playgroud)

httpresponse zipfile asp.net-web-api angularjs pushstreamcontent

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

如何用空字符串替换undefined

我正在使用jsPdf.当一个字段留空时,"未定义"将打印在pdf上.我想用空字符串替换它.我试图使用if语句,但我没有得到它.

 doc.text(30, 190, "Budget : $");
    if ($scope.currentItem.JobOriginalBudget == "undefined") {

        doc.text(50, 190, " ");
    }
    else {
        var y = '' + $scope.currentItem.JobOriginalBudget;
        doc.text(50, 190, y);
    };
Run Code Online (Sandbox Code Playgroud)

javascript angularjs jspdf

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

如何使用角度路由嵌套3 mvc剃刀模型

我想拥有一个UsersAdmin视图,其中包含Account Registration,UserProfile类和Identity Role类.我使用MVC5默认个人身份验证.我正在使用ui-router进行路由.我见过许多使用viewmodel将多个模型传递给单个cshtml视图的示例.但我需要一个更复杂的设置.我创建了一个模拟我正在寻找的东西.做这个的最好方式是什么. 小样

这是我的设置的样子

UI路由

 // Default route
    $urlRouterProvider.otherwise('/Document');

    // Application Routes States
    $stateProvider
      .state('app', {
          abstract: true,
          controller: "CoreController",
          resolve: {
              _assets: Route.require('icons', 'toaster', 'animate')
          }
      })
      .state('app.document', {
          url: '/Document',
          templateUrl: Route.base('Document/Index'),
          resolve: {}
      })
      .state('app.register', {
          url: '/Register',
          templateUrl: Route.base('Account/Register'),
          resolve: {}
      }).state('app.applicationUser', {
          url: '/ApplicationUser',
          templateUrl: Route.base('ApplicationUsers/Index'),
          resolve: {}
      }).state('app.role', {
           url: '/Role',
           templateUrl: Route.base('Role/Index'),
           resolve: {}
     }).state('app.roleCreate', {
           url: '/RoleCreate',
          templateUrl: Route.base('Role/Create'),
          resolve: {}
     }).state('app.userProfile', {
         url: '/UserProfile',
         templateUrl: Route.base('UserProfiles/Index'),
         resolve: {}
     }).state('app.userProfileCreate', {
         url: …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc razor angularjs angular-ui-router

12
推荐指数
1
解决办法
849
查看次数

如何修复css导航闪烁问题

我有一个使用reactstrap(bootstrap4)的反应应用程序.我使用react-router为导航创建了一个简单的布局.我无法弄清楚为什么导航栏项目会在您单击时闪烁.我正在使用来自react-router-dom的内置NavLink,它可以突出显示所选的NavItem.

这是网站网站的链接

标题组件

import {
  Collapse,
  Navbar,
  NavbarToggler,
  Nav,
  NavItem,
  NavbarBrand,
  NavLink } from 'reactstrap'
import { NavLink as RRNavLink } from 'react-router-dom'

const Item = ({link, label}) => (
  <NavItem>
    <NavLink exact activeClassName='active-tab' to={link} tag={RRNavLink}>{label}</NavLink>
  </NavItem>
)

const ROUTES = []

export default class extends React.Component {
  render () {
    return (
      <div className='header-bkg'>
        <Navbar color='faded' light expand='md'>
          <NavbarBrand className='text-white'>Star Designs</NavbarBrand>
          <NavbarToggler onClick={this._onToggle} />
          <Collapse isOpen={this.state.isOpen} navbar>
            <Nav className='ml-auto' navbar>
              {ROUTES.map((x, i) => (
                <Item key={i} {...x} …
Run Code Online (Sandbox Code Playgroud)

html css reactjs react-router-v4

11
推荐指数
1
解决办法
515
查看次数

如何在bootstrap模式内设置kendo-ui网格输入的输入焦点

在将我的kendo-ui网格移动到bootstrap模式中之前,我会点击A​​dd Row,然后选择3个输入中的第一个.然后我会选择第二个,然后是第三个然后选项卡到复选框按钮,我将按下回车键并添加行.然后焦点将返回到"添加行"按钮,我可以按Enter键再次开始处理.那么现在它在一个模态中我失去了除了标签之外的一切.我找到了使用jquery来应用焦点的解决方案,但我已经在我的网格控制器中有了它.

Kendo-ui网格控制器

 $scope.mainGridOptions = {
        dataSource: dataSource,
        pageable: false,
        toolbar: [{ name: "create", text: "Add Product", }],
        columns: [
        { field: "product", title: "Product", width: "95px", editor: productEditor },
        {
            field: "price", title: "Price", width: "95px", format: "{0:c2}", editor: priceEditor
        },
        {
            field: "sqft", title: "Square Feet", width: "95px", editor: sqftEditor
        },
        {
            command: [{ name: 'edit', text: { edit: '', update: '', cancel: '' }, width: '20px' }, { name: 'destroy', text: '' }], title: '&nbsp;', width: '80px' …
Run Code Online (Sandbox Code Playgroud)

javascript jquery twitter-bootstrap kendo-ui kendo-grid

10
推荐指数
1
解决办法
1620
查看次数

如何设置ui-router嵌套视图

我正在尝试使用ui-router设置我的应用程序.我熟悉基本的嵌套视图,但我想做一些更复杂的事情.我有主要视图的基本设置.我想有一个聊天弹出窗口,它有自己独立于主视图的视图.我希望能够导航主视图,而不会影响聊天弹出窗口中的状态.那怎么办?我是否需要为聊天提供抽象状态?然后从那里嵌套视图?

这是一个视觉. 布局

这是一个掠夺者

plunker

 $stateProvider
    .state('root', {
      abstract: true,
      views: {
        '@': {
            template: '<ui-view />',
            controller: 'RootCtrl',
            controllerAs: 'rootCtrl'
        },
        'header@': {
            templateUrl: 'header.html',
            controller: 'HeaderCtrl',
            controllerAs: 'headerCtrl'
        },
        'footer@': {
            templateUrl: 'footer.html',
            controller: 'FooterCtrl',
            controllerAs: 'footerCtrl'
            }
       }
    })
    .state('root.home',{
        parent:'root',
        url:'/home',
        templateUrl:'home.html',
        controller: 'HomeController',
        controllerAs:'homeCtrl'
    })
     .state('root.about',{
        parent:'root',
        url:'/about',
        templateUrl:'about.html'
    });
});
Run Code Online (Sandbox Code Playgroud)

nested angularjs angular-ui-router

10
推荐指数
1
解决办法
288
查看次数

如何解决反应本机EventEmitterListener警告

我正在使用事件发射器在地图组件和工具栏之间进行通信.注意*我在我的应用程序的其他部分使用相同的代码没有问题.我得到的错误是:

警告:setState(...):只能更新已安装或安装的组件.这通常意味着您在已卸载的组件上调用了setState().这是一个无操作.请检查未定义组件的代码.

我试图通过类似的帖子解决这个问题,但它不起作用.我认为它与两个组件中的mount && unmount方法有关?

工具栏组件

        componentDidMount() {
    this.showLocateIconListener = AppEventEmitter.addListener('isTrip', this.isTrip.bind(this));
    this.endTripListener = AppEventEmitter.addListener('showLocateIcon', this.showLocateIcon.bind(this));
    this.endSubdivisionIcon = AppEventEmitter.addListener('showSubdivisionIcon', this.showSubdivisionIcon.bind(this));
}

componentWillUnMount() {
    this.showLocateIconListener.remove();
    this.endTripListener.remove();
    this.endSubdivisionIcon.remove();
}


 //// this is where the error is happening
showSubdivisionIcon(val) {
    if (val != 0)
        this.setState({
            items: menuSubdivision,
            subdivisionId: val
        })
    else
        this.setState({
            items: menu
        })
}
Run Code Online (Sandbox Code Playgroud)

地图组件

  onMarkerPress(val) {
    AppEventEmitter.emit('showSubdivisionIcon', val.id);
}
Run Code Online (Sandbox Code Playgroud)

EventEmitter.js的控制台错误详细信息导致了这一点

  subscription.listener.apply(
        subscription.context,
        Array.prototype.slice.call(arguments, 1)
      );
Run Code Online (Sandbox Code Playgroud)

EventEmitter.js中的完整部分

      /**
   * Emits an event of the given type with the given data. All …
Run Code Online (Sandbox Code Playgroud)

javascript node.js eventemitter reactjs react-native

10
推荐指数
1
解决办法
1645
查看次数

react-native listview一些行不显示

我有一个带有3个标签的模态.每个选项卡都有一个列表视图,任何大于10行的数据集都无法正常工作.发生的是初始加载它正确显示.但是当显示更多行时,它们都是空的.不确定发生了什么.使用最新的React-Native.如果它有帮助,这里有几个截图.

pic 1pic 2pic 3

 <View style={{flex:1, height: this.state.visibleHeight - 100, width: this.state.visibleWidth }}>
    {
      (this.state.isSubdivisions) ? <Subdivisions model={this.props.model.subdivisions}/>
      : (this.state.isProspects) ? <LandProspects model={this.props.model.landProspects}/>
      : (this.state.isFavorites) ? <Favorites model={this.props.model.favorites}/>
      : null}
</View>
Run Code Online (Sandbox Code Playgroud)

标签

class ListLandProspects extends Component {
  constructor(props) {
    super(props);
    const foo = this.props.model.slice(0,10)
    const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
    this.state = {
      dataSource: ds.cloneWithRows(foo),
      deviceHeight: Dimensions.get('window').height,
      deviceWidth: Dimensions.get('window').width
    }
  }

  componentDidUpdate(prevProps) {
    if (this.props.model != prevProps.model)
    this._updateLandProspects()
  }

  _updateLandProspects(){
    const clone = this.props.model.slice()
    this.setState({
      dataSource: this.state.dataSource.cloneWithRows(clone)
    }) …
Run Code Online (Sandbox Code Playgroud)

listview reactjs react-native react-native-listview

10
推荐指数
1
解决办法
382
查看次数